X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fparser.c;h=a63f532c48427f3510c5ea2cc7c563c6e5b99259;hb=955bdb1d32b279ea7a773dba66ac375d98d71740;hp=0a994a3f30be699d7dfa6e6756f701caeaeb839c;hpb=fbd607dd560afe44c3b90de1e6cbe5265cac8f1e;p=ffmpeg diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 0a994a3f30b..a63f532c484 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -245,6 +245,9 @@ int ff_combine_frame(ParseContext *pc, int next, for (; pc->overread > 0; pc->overread--) pc->buffer[pc->index++] = pc->buffer[pc->overread_index++]; + if (next > *buf_size) + return AVERROR(EINVAL); + /* flush remaining if EOF */ if (!*buf_size && next == END_NOT_FOUND) next = 0; @@ -292,6 +295,10 @@ int ff_combine_frame(ParseContext *pc, int next, *buf = pc->buffer; } + if (next < -8) { + pc->overread += -8 - next; + next = -8; + } /* store overread bytes */ for (; next < 0; next++) { pc->state = pc->state << 8 | pc->buffer[pc->last_index + next];