Browse code

Prevent overflow on random input.

Originally committed as revision 24795 to svn://svn.ffmpeg.org/ffmpeg/trunk

Ronald S. Bultje authored on 2010/08/14 05:06:18
Showing 1 changed files
... ...
@@ -230,7 +230,8 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
230 230
                 int prev_len = out_len;
231 231
                 out_len += cur_len;
232 232
                 asf->buf = av_realloc(asf->buf, out_len);
233
-                memcpy(asf->buf + prev_len, buf + off, cur_len);
233
+                memcpy(asf->buf + prev_len, buf + off,
234
+                       FFMIN(cur_len, len - off));
234 235
                 url_fskip(pb, cur_len);
235 236
             }
236 237
         }