mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
log:Sanitize string of most control chars before printing.
This may be security relevant depending upon the used terminal. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
eea4fa0591
commit
0a51362b3f
@ -82,6 +82,14 @@ const char* av_default_item_name(void* ptr){
|
|||||||
return (*(AVClass**)ptr)->class_name;
|
return (*(AVClass**)ptr)->class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sanitize(uint8_t *line){
|
||||||
|
while(*line){
|
||||||
|
if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
|
||||||
|
*line='?';
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
|
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
|
||||||
{
|
{
|
||||||
static int print_prefix=1;
|
static int print_prefix=1;
|
||||||
@ -121,8 +129,9 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
|
|||||||
fprintf(stderr, " Last message repeated %d times\n", count);
|
fprintf(stderr, " Last message repeated %d times\n", count);
|
||||||
count=0;
|
count=0;
|
||||||
}
|
}
|
||||||
colored_fputs(av_clip(level>>3, 0, 6), line);
|
|
||||||
strcpy(prev, line);
|
strcpy(prev, line);
|
||||||
|
sanitize(line);
|
||||||
|
colored_fputs(av_clip(level>>3, 0, 6), line);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
|
static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
|
||||||
|
Loading…
Reference in New Issue
Block a user