mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-19 09:02:26 +02:00
avcodec/mjpeg_parser: Make parser a bit more robust with unclean input
Helps: test_roman.mjpeg (note this is not really just mjpeg) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
27522fb64c
commit
ec3d8a0e69
@ -50,7 +50,7 @@ static int find_frame_end(MJPEGParserContext *m, const uint8_t *buf, int buf_siz
|
|||||||
for(i=0; i<buf_size;){
|
for(i=0; i<buf_size;){
|
||||||
state= (state<<8) | buf[i];
|
state= (state<<8) | buf[i];
|
||||||
if(state>=0xFFC00000 && state<=0xFFFEFFFF){
|
if(state>=0xFFC00000 && state<=0xFFFEFFFF){
|
||||||
if(state>=0xFFD80000 && state<=0xFFD8FFFF){
|
if(state>=0xFFD8FFC0 && state<=0xFFD8FFFF){
|
||||||
i++;
|
i++;
|
||||||
vop_found=1;
|
vop_found=1;
|
||||||
break;
|
break;
|
||||||
@ -76,12 +76,14 @@ static int find_frame_end(MJPEGParserContext *m, const uint8_t *buf, int buf_siz
|
|||||||
for(; i<buf_size;){
|
for(; i<buf_size;){
|
||||||
state= (state<<8) | buf[i];
|
state= (state<<8) | buf[i];
|
||||||
if(state>=0xFFC00000 && state<=0xFFFEFFFF){
|
if(state>=0xFFC00000 && state<=0xFFFEFFFF){
|
||||||
if(state>=0xFFD80000 && state<=0xFFD8FFFF){
|
if(state>=0xFFD8FFC0 && state<=0xFFD8FFFF){
|
||||||
pc->frame_start_found=0;
|
pc->frame_start_found=0;
|
||||||
pc->state=0;
|
pc->state=0;
|
||||||
return i-3;
|
return i-3;
|
||||||
} else if(state<0xFFD00000 || state>0xFFD9FFFF){
|
} else if(state<0xFFD00000 || state>0xFFD9FFFF){
|
||||||
m->size= (state&0xFFFF)-1;
|
m->size= (state&0xFFFF)-1;
|
||||||
|
if (m->size >= 0x8000)
|
||||||
|
m->size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(m->size>0){
|
if(m->size>0){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user