[FFmpeg-devel] [PATCH] misc libvorbis.c fixes

Alex Converse alex.converse
Tue Jun 29 09:33:47 CEST 2010


On Tue, Jun 29, 2010 at 3:24 AM, Pascal Massimino
<pascal.massimino at gmail.com> wrote:
> On Sun, Jun 27, 2010 at 7:40 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
>
>> Pascal Massimino <pascal.massimino <at> gmail.com> writes:

Welcome back skal, I hope you'll stay a while.

>> > $subj. Namely:
>> > * remove an unneeded av_realloc()
>> > * add some buffer checks
>> > * use ?avccontext->frame_size where appropriate
>>
>> Please send one patch per issue.
>>
>>
> attached.
>

Normally I'm not one to be pedantic about this sort of thing but...

> vorbis-1: remove an unneeded av_realloc()
@@ -104,9 +107,10 @@
     vorbis_analysis_headerout(&context->vd, &context->vc, &header,
                                 &header_comm, &header_code);

-    len = header.bytes + header_comm.bytes +  header_code.bytes;
-    avccontext->extradata_size= 64 + len + len/255;
-    p = avccontext->extradata= av_mallocz(avccontext->extradata_size);
+    avccontext->extradata_size=
+        1 + xiph_len(header.bytes) + xiph_len(header_comm.bytes)
+         + header_code.bytes;
+    p = avccontext->extradata = av_malloc(avccontext->extradata_size);
     p[0] = 2;
     offset = 1;
     offset += av_xiphlacing(&p[offset], header.bytes);

This indentation seems really strange.

> vorbis-3: add some buffer checks
@@ -190,6 +197,11 @@
         avccontext->coded_frame->pts= av_rescale_q(op2->granulepos,
(AVRational){1, avccontext->sample_rate}, avccontext->time_base);
         //FIXME we should reorder the user supplied pts and not
assume that they are spaced by 1/sample_rate

+        if (l > buf_size) {
+          av_log(avccontext, AV_LOG_ERROR, "libvorbis: buffer overflow.");
+          return -1;
+        }
+
         memcpy(packets, op2->packet, l);
         context->buffer_index -= l + sizeof(ogg_packet);
         memmove(context->buffer, context->buffer + l +
sizeof(ogg_packet), context->buffer_index);

4 spaces is the standard indentation in FFmpeg and seems to followed
consistently in libvorbis.c



More information about the ffmpeg-devel mailing list