summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-08-03 22:02:17 +0200
committerHendrik Leppkes <h.leppkes@gmail.com>2015-08-04 20:04:53 +0200
commit2ab5002e3cd27cfa8f70035369d554c97739c4d0 (patch)
tree47252aaca357258a963d6f69bb54ac777b1f402d /ffmpeg.c
parent3c8652208b1a7a9765f696b56b747f1f72634a62 (diff)
downloadffmpeg-2ab5002e3cd27cfa8f70035369d554c97739c4d0.tar.gz
ffmpeg: avoid scanf in keyboard command parsing
Mixing stdio and low-level IO on stdin is not safe.
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 5575e2f9a4..206b3dc4a2 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3428,9 +3428,17 @@ static int check_keyboard_interaction(int64_t cur_time)
if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash
debug += debug;
- }else
- if(scanf("%d", &debug)!=1)
+ }else{
+ char buf[32];
+ int k = 0;
+ i = 0;
+ while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
+ if (k > 0)
+ buf[i++] = k;
+ buf[i] = 0;
+ if (k <= 0 || sscanf(buf, "%d", &debug)!=1)
fprintf(stderr,"error parsing debug value\n");
+ }
for(i=0;i<nb_input_streams;i++) {
input_streams[i]->st->codec->debug = debug;
}