diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-03-25 00:20:07 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-03-25 01:16:22 +0100 |
commit | 0a51362b3f3c3a0df09b24fbd9049711bff6fb94 (patch) | |
tree | c0c80fb521d4252204a1e9b250309a0ee5d0ef30 | |
parent | eea4fa059134253cf720c7fa2045b011723c60ef (diff) | |
download | ffmpeg-0a51362b3f3c3a0df09b24fbd9049711bff6fb94.tar.gz |
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>
-rw-r--r-- | libavutil/log.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libavutil/log.c b/libavutil/log.c index 6c9e76aa24..b3c935889a 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -82,6 +82,14 @@ const char* av_default_item_name(void* ptr){ 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) { 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); count=0; } - colored_fputs(av_clip(level>>3, 0, 6), 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; |