From patchwork Fri May 12 19:13:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Meyers X-Patchwork-Id: 3661 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp465453vsd; Fri, 12 May 2017 12:13:43 -0700 (PDT) X-Received: by 10.223.160.70 with SMTP id l6mr4750089wrl.0.1494616423850; Fri, 12 May 2017 12:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494616423; cv=none; d=google.com; s=arc-20160816; b=S3oe7OJFXATY6GOgax2+YLtX58y0bhWBXnlFkCWWtuJYE+3E34qONyNeLHuw8SZ0QP sZKySpxeYMj8GSAPHX0VDDLeop5WfKIbbTNIGJEpNrN+3IcOGlbxXOItLGURvRpxZ66V 32HcyyYAl4Quel31wWpUWfyJ+qZdduXBxqBkZTA5hLDnZO8nj4Xn5USwb2/Ff6/7OuIM i+5z9qg+X1xuibhCZ54HfGwO8iCZwje/63ovz1XBUNtlE/DpMz//diKk4dsK/9lld1zP 9xbZOLiq1zM3RxX8K+IObHDkbLxDHDiv3zrjCjx9tMXmz6n00ELyUt2ZRL95XH4zIVNh u4uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=EJ29LWmkT6uXJzeDniACu2X5BSKtRR5uM0zC9FyqWZg=; b=pM8qXJW10ubyzHr4/wCTuPTcNKXLR2csJJBn5DBE+htw+LXO0cMxBYsMqAecRSQZRK v/8lltWa350RZPA6j8a38YveukwKwa099Y3JJw5aXjh54OhT6uGgt+BdMSaJxv5MWRye F6WJZcaMXhzep+9lfObk4LYLTp7+XfKbg+llId6Kx72FqnhlB1x84c38jA+cwU7XR0+9 0x9NJEhoDdVVXe3ZOJC7ALGMYNBR6Md99/rocAEuTmSX1QLU5MmnVJnASMRLhj64GVCh xCPx1i2/+TTfZ86lzfs9BDptVacFjHLW+E2L7vFSl0UzZeM+GbwHa7qMNLDJxlhXH5rY BUuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j71si3136791wmj.122.2017.05.12.12.13.43; Fri, 12 May 2017 12:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8669A688249; Fri, 12 May 2017 22:13:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f173.google.com (mail-qt0-f173.google.com [209.85.216.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 84C8568066B for ; Fri, 12 May 2017 22:13:25 +0300 (EEST) Received: by mail-qt0-f173.google.com with SMTP id l7so13722978qte.1 for ; Fri, 12 May 2017 12:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=PKOn62g06nWBN9qA7Y+oKeAVV0tm5ozwOb2ldzDiPXA=; b=QJ8/8roJZo8W9syWOiAggHS4jqc3EvZEBe7UJ+YNjw7yH9OtnbwjaouO+AMzYTC0hz SyE5Og1TcQLYLI+k8J89y1JT5+mv6qby8yKnrPMrP2iaB0+7XulLYnnMJMciW4/C8pf/ b4qlpmHXIVQN+vz/e/g5loH3Hxoi4BFCrllGrlOBbXY5dAi1fcsrvGFeg7DGBEfNLwpX e90J+2EX8lrYss9rz97XFM1e23zdEXv2N9neMEhu9Q4Avzk95p+jtWT+DX4Z9Ok3BILn rPhTZIXxLEEp1KydJVUyd6DmUsBr55eyZjnefszag9JH8PvOIcNrmazBpreLQb/9AtEJ dyUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=PKOn62g06nWBN9qA7Y+oKeAVV0tm5ozwOb2ldzDiPXA=; b=U8uvmywRNMA75kcix/HwIHa1Jp3P+SZ5hoD0MFqt4aK+e0KZsoR2cAesgDHWwJHeAa pvQbPV8YTG0AWLCzVvFGNt19AhosUTP+gc7wE+tN98mgjxRD1h11kSK9AHF1ycyHLkPL s7iTxcx87ZaBhfdNDB7LVKRhiygwd4qAYKIFvzXXXYRV0DH969KGm6/LU2cEtXRttpip 6JAQ113IlJogxB2VVdJuLw4ApgXKQWd/+dIbG+GJ2K9s3QuzJdeO3k7wKwpAZTMfXbkW X2n/qs91CBKbSz718uihshiisZNFa0dDVN7CkcP30MilFrziTSF67hmePqAGpB1N2hD/ sZXw== X-Gm-Message-State: AODbwcB6HAmyKP9otj/B7mGYag5Hjd+NOD5pwerL/DU8znbstu/ymOWF 2ud6xySK+v3Xf9Oq+PeuF0SkHA7agPxNzL4= X-Received: by 10.200.50.49 with SMTP id x46mr5729933qta.105.1494616411744; Fri, 12 May 2017 12:13:31 -0700 (PDT) MIME-Version: 1.0 References: <20170512185033.GU4759@nb4> In-Reply-To: <20170512185033.GU4759@nb4> From: Rob Meyers Date: Fri, 12 May 2017 19:13:21 +0000 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] Patch libavformat/aviobuf.c fixes data loss on named pipe reads X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Attaching the output of "git diff -p". On Fri, May 12, 2017 at 11:50 AM Michael Niedermayer 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 > 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);