# HG changeset patch # User michael # Date 1096646400 0 # Node ID 78a8cbdad2697c791120e8d2c869777352fcd2d5 # Parent d2cc9c6f5d98712029c90ca00e9b125e4ec4f705 64bit and reading over the end of the array fixes diff -r d2cc9c6f5d98 -r 78a8cbdad269 mpeg.c --- a/mpeg.c Fri Oct 01 13:32:13 2004 +0000 +++ b/mpeg.c Fri Oct 01 16:00:00 2004 +0000 @@ -1026,21 +1026,18 @@ static int mpegps_probe(AVProbeData *p) { - int code, c, i; + int i; + int size= FFMIN(20, p->buf_size); + uint32_t code=0xFF; - code = 0xff; /* we search the first start code. If it is a packet start code, then we decide it is mpeg ps. We do not send highest value to give a chance to mpegts */ /* NOTE: the search range was restricted to avoid too many false detections */ - if (p->buf_size < 6) - return 0; - - for (i = 0; i < 20; i++) { - c = p->buf[i]; - code = (code << 8) | c; + for (i = 0; i < size; i++) { + code = (code << 8) | p->buf[i]; if ((code & 0xffffff00) == 0x100) { if (code == PACK_START_CODE || code == SYSTEM_HEADER_START_CODE ||