ffmpeg: avoid scanf in keyboard command parsing

Mixing stdio and low-level IO on stdin is not safe.
pull/144/head
Hendrik Leppkes 9 years ago
parent 3c8652208b
commit 2ab5002e3c
  1. 12
      ffmpeg.c

@ -3428,9 +3428,17 @@ static int check_keyboard_interaction(int64_t cur_time)
if(!debug) debug = 1; if(!debug) debug = 1;
while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash
debug += debug; debug += debug;
}else }else{
if(scanf("%d", &debug)!=1) 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"); fprintf(stderr,"error parsing debug value\n");
}
for(i=0;i<nb_input_streams;i++) { for(i=0;i<nb_input_streams;i++) {
input_streams[i]->st->codec->debug = debug; input_streams[i]->st->codec->debug = debug;
} }

Loading…
Cancel
Save