Browse Source

avio: Check for invalid buffer length.

(cherry picked from commit ab2940691b)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
tags/n0.8.6
Alex Converse Michael Niedermayer 14 years ago
parent
commit
e86e9f8b7a
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      libavformat/aviobuf.c

+ 5
- 2
libavformat/aviobuf.c View File

@@ -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;\


Loading…
Cancel
Save