diff mbox

[FFmpeg-devel] Patch libavformat/aviobuf.c fixes data loss on named pipe reads

Message ID CALvomiMFezjUBwZCZndySCXqNYhvh6_ngFri7K8E6s+AVKXi-A@mail.gmail.com
State New
Headers show

Commit Message

Rob Meyers May 12, 2017, 7:13 p.m. UTC
Attaching the output of "git diff -p".

On Fri, May 12, 2017 at 11:50 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Fri, May 12, 2017 at 06:31:19PM +0000, Rob Meyers wrote:
> > Submitting a patch to fix a bug in ffmpeg found when reading data from a
> > named pipe. In our test, a pipe sending twelve bytes in two 6 byte
> messages
> > results in the first 10 bytes being lost. We found the problem was
> > introduced with this commit (2ca48e466675a8a3630061cd2c15325eab8eda97) on
> > June 30, 2013. In this code, the "dst" pointer is always set to
> s->buffer,
> > and earlier message bytes are overwritten by later ones when assembling a
> > packet from multiple small reads.
> >
> Patch is corrupted by linebreaks
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Let us carefully observe those good qualities wherein our enemies excel us
> and endeavor to excel them, by avoiding what is faulty, and imitating what
> is excellent in them. -- Plutarch
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Comments

Moritz Barsnick May 13, 2017, 9 p.m. UTC | #1
On Fri, May 12, 2017 at 19:13:21 +0000, Rob Meyers wrote:
> Attaching the output of "git diff -p".

That will work, but
$ git format-patch --signoff
is recommended:
https://ffmpeg.org/developer.html#Submitting-patches

Your method lost the commit message (which was incorrectly worded
anyway ;-)).

Moritz
James Almer May 13, 2017, 11:10 p.m. UTC | #2
On 5/13/2017 6:00 PM, Moritz Barsnick wrote:
> On Fri, May 12, 2017 at 19:13:21 +0000, Rob Meyers wrote:
>> Attaching the output of "git diff -p".
> 
> That will work, but
> $ git format-patch --signoff
> is recommended:
> https://ffmpeg.org/developer.html#Submitting-patches

git format-patch is a minimum. git send-email is encouraged/recommended.

> 
> Your method lost the commit message (which was incorrectly worded
> anyway ;-)).
> 
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
diff mbox

Patch

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 0a7c39eacd..4e04cb79e0 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -519,9 +519,7 @@  void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType typ
 
 static void fill_buffer(AVIOContext *s)
 {
-    int max_buffer_size = s->max_packet_size ?
-                          s->max_packet_size : IO_BUFFER_SIZE;
-    uint8_t *dst        = s->buf_end - s->buffer + max_buffer_size < s->buffer_size ?
+    uint8_t *dst        = !s->max_packet_size && s->buf_end - s->buffer < s->buffer_size ?
                           s->buf_end : s->buffer;
     int len             = s->buffer_size - (dst - s->buffer);