[FFmpeg-cvslog] avio: Check for invalid buffer length.

Alex Converse git at videolan.org
Fri Nov 4 20:49:26 CET 2011


ffmpeg | branch: release/0.7 | Alex Converse <alex.converse at gmail.com> | Fri Oct 14 18:27:59 2011 -0700| [e86e9f8b7acd8c68a3d4fefc803756d7ee8737eb] | committer: Michael Niedermayer

avio: Check for invalid buffer length.
(cherry picked from commit ab2940691ba76e1a9b0ce608db0dfc45021d741e)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/aviobuf.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index c6a67c3..1f79531 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -778,13 +778,14 @@ int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
 {
     int i;
 
+    if (buflen <= 0)
+        return AVERROR(EINVAL);
     // reserve 1 byte for terminating 0
     buflen = FFMIN(buflen - 1, maxlen);
     for (i = 0; i < buflen; i++)
         if (!(buf[i] = avio_r8(s)))
             return i + 1;
-    if (buflen)
-        buf[i] = 0;
+    buf[i] = 0;
     for (; i < maxlen; i++)
         if (!avio_r8(s))
             return i + 1;
@@ -796,6 +797,8 @@ int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen)
 {\
     char* q = buf;\
     int ret = 0;\
+    if (buflen <= 0) \
+        return AVERROR(EINVAL); \
     while (ret + 1 < maxlen) {\
         uint8_t tmp;\
         uint32_t ch;\



More information about the ffmpeg-cvslog mailing list