[FFmpeg-cvslog] flacdec: simplify bounds checking in flac_probe()

Xi Wang git at videolan.org
Sun Oct 6 19:06:12 CEST 2013


ffmpeg | branch: release/0.7 | Xi Wang <xi.wang at gmail.com> | Fri Mar 15 07:11:47 2013 -0400| [f8d3bb8961d2cdea38ae2971436deae556d78f08] | committer: Reinhard Tartler

flacdec: simplify bounds checking in flac_probe()

Simplify `p->buf > p->buf + p->buf_size - 4' as `p->buf_size < 4'.
Avoid a possible out-of-bounds pointer, which is undefined behavior
in C.

CC: libav-stable at libav.org

Signed-off-by: Xi Wang <xi.wang at gmail.com>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

(cherry picked from commit 8425d693eefbedbb41f91735614d41067695aa37)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f8d3bb8961d2cdea38ae2971436deae556d78f08
---

 libavformat/flacdec.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 02452b4..32b583f 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -116,11 +116,9 @@ static int flac_read_header(AVFormatContext *s,
 
 static int flac_probe(AVProbeData *p)
 {
-    uint8_t *bufptr = p->buf;
-    uint8_t *end    = p->buf + p->buf_size;
-
-    if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
-    else                                            return AVPROBE_SCORE_MAX/2;
+    if (p->buf_size < 4 || memcmp(p->buf, "fLaC", 4))
+        return 0;
+    return AVPROBE_SCORE_MAX/2;
 }
 
 AVInputFormat ff_flac_demuxer = {



More information about the ffmpeg-cvslog mailing list