From patchwork Mon Mar 20 21:49:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fredrik Hubinette X-Patchwork-Id: 3033 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp1584144vsy; Mon, 20 Mar 2017 14:49:29 -0700 (PDT) X-Received: by 10.223.138.134 with SMTP id y6mr27298987wry.118.1490046569506; Mon, 20 Mar 2017 14:49:29 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l62si24834507wrc.6.2017.03.20.14.49.28; Mon, 20 Mar 2017 14:49:29 -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 BA7056883D9; Mon, 20 Mar 2017 23:49:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BCE6A688394 for ; Mon, 20 Mar 2017 23:49:01 +0200 (EET) Received: by mail-wr0-f171.google.com with SMTP id u108so101000261wrb.3 for ; Mon, 20 Mar 2017 14:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=edTaPKmIHy948uy6FyCTmb2XbdF3eEnRQ+tWTJnGVu0=; b=r7VQtpwjdyBsOXe7YIe6IV5KF9oP9pnGRaKMP2g/LIUFCRBHMRkaSy4jkJ1aidmrDV yP+57sVxFRlD7gHPWtKFj1RelVBbz9G6T0ZzRseafwfR7LW8sSqETcRTQntYZfXzox+n r5NQoLrVeEU3+Rc5mTjV0ATMEA3h5Z6WSvIWTRto7SJ/CheqOooWfRNPqaMLS9Q9Lr2R kMLOTfQn7R21jZrDZKhf/lQTnRE4ZooDnGY0v7ipjUW8ctjpW7SWe0R625F3dSd/Lfhp a/yBrj72CiNg/2u/TVvSTHC5G3pPxLPvukfh+8yWP9IUP6l47sPHYBgEdkMXY2/NQ81t MFLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=edTaPKmIHy948uy6FyCTmb2XbdF3eEnRQ+tWTJnGVu0=; b=e5fWWYZbCILJf0SrywPQSZZJqWGOEnY6cGAo20YIBRWyj7bU9XXFAlHdMqRpwvbEpF MUEWQ3JGIZcR8lr/D7X9RObACvovVI+QkpkmS26DSC6Uog4t/mx06vqUgfDwvVotyvuW O72IpO57jT5ad86HKZtUTZgF9nQ2NlNpAU+BUORHWTh2NzMYVnI4lwHqfRwTxq37ahxM Xw819jvZQJIWlgwBonRYX1IhyyFyDvrmimpHfJMleJI5p0gU8r4xaxvNuYRysEEapxjL AJvMdMg6h1g/OY+mnJYYK1VneeyE1TMJh3pa3caajlnLQkX26OEFSSImlKe1F97JFx4C sJ5g== X-Gm-Message-State: AFeK/H2dprk7yQ/abdfQdKLiMR4URVAlo+gna6yt0fllsp9yhghHpRGJaOBI1ILIIknlQ/YBQlHPYFxWN2mK4ZFP X-Received: by 10.223.163.21 with SMTP id c21mr26784254wrb.115.1490046559107; Mon, 20 Mar 2017 14:49:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.230.133 with HTTP; Mon, 20 Mar 2017 14:49:18 -0700 (PDT) In-Reply-To: References: <20170320203522.GQ5776@nb4> From: Fredrik Hubinette Date: Mon, 20 Mar 2017 14:49:18 -0700 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] clear s->error in avio_read 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" Hopefully valid patch attached. On Mon, Mar 20, 2017 at 2:39 PM, Fredrik Hubinette wrote: > It looks like the value in s->error also comes from an earlier call to > avio_read(). > ogg_read_page tries to read 4439 bytes from the file. It has 524 bytes > already buffered. > fill_buffer() fails with an EIO, but because of the buffered bytes, > avio_read() > returns 524 and leaves the EIO in s->error. > > /Fredrik "Hubbe" Hubinette > > > On Mon, Mar 20, 2017 at 1:53 PM, Fredrik Hubinette > wrote: > >> >> On Mon, Mar 20, 2017 at 1:35 PM, Michael Niedermayer < >> michael@niedermayer.cc> wrote: >> >>> On Mon, Mar 20, 2017 at 10:21:08AM -0700, Fredrik Hubinette wrote: >>> > In some cases (when parsing OGG) non-fatal errors can happen, which >>> > will cause s->error to be set. In most cases, this is not a problem >>> beucase >>> > s->error is not checked unless an actual error has occurred. However, >>> > when avio_read() fails to read more bytes, it checks s->error to >>> decide if >>> > it just reached the end of the file, or an error occurred. Since >>> s->error is >>> > not modified if no error occurred, this is not reliable unless we first >>> > clear >>> > s->error before reading. >>> > >>> > --- >>> > libavformat/aviobuf.c | 2 ++ >>> > >>> > 2 files changed, 7 insertions(+) >>> >>> how can the issue you describe be reproduced >>> >>> >> I don't currently have a simple repro. I discovered it while trying to >> add some buffering >> between the demuxer and decoder in chrome. One of our tests fails, and >> when >> looked into it, I discovered that s->error was already 5 (EIO) when >> entering >> avio_read. I have not yet tracked down where the EIO came from >> originally. >> >> also thats not a valid git patc >>> >> >> Ops, I had a chrome patch and I removed the chrome-specific parts, but >> I must have messed it up. I will make a better patch. >> >> >>> [...] >>> -- >>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB >>> >>> Those who are best at talking, realize last or never when they are wrong. >>> >>> _______________________________________________ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>> >>> >> > From a26c186d2ac6d013215e9707fa3508ba1ef8537a Mon Sep 17 00:00:00 2001 From: Fredrik Hubinette Date: Mon, 20 Mar 2017 14:47:06 -0700 Subject: [PATCH] clear s->error in avio_read --- libavformat/aviobuf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 4ade4d0d7e..0912dfdb57 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -615,6 +615,8 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) { int len, size1; + s->error = 0; + size1 = size; while (size > 0) { len = FFMIN(s->buf_end - s->buf_ptr, size); -- 2.12.0.367.g23dc2f6d3c-goog