From patchwork Wed Aug 21 09:04:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 14638 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 701BE447EBB for ; Wed, 21 Aug 2019 12:14:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5FF8268AB65; Wed, 21 Aug 2019 12:14:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33E3468023F for ; Wed, 21 Aug 2019 12:14:13 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id k1so1337671wmi.1 for ; Wed, 21 Aug 2019 02:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jxl6byxMVAoZkSezbIH1w9jWKiELAtwhd65uwT5pyi8=; b=Bh/5d32syK6tnt/O9+wmWrAPyx8WXjcPp3nh0sKdo1Zbd1CKD8X8vpLB4k49de6VpD X8Z0NNT7QmJXTb6fr8Ja7YmDITrGOY9iH8Q5UKkAHioXMZwnpQ09bS+BB67GKlKvLTbD SMb26xvOMJNsBcFEGK8nzYAmFXOJsf9QaUifn9tQzfqLox3++BMLCAkwWkN1dpSUS6IO 6Cf29fUoSfhwPTVJQDg8I6F3B8LVlUrOHsXFLS3NBU6qc7N8zIklyKdDBkgaH4c6GaE1 5/rLBGCcTqbuIrpM+FbmE7/vLD68xI7EBIwJUTzkKOkvb+oEwEm710qKhgKkcgcq4O35 tqHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jxl6byxMVAoZkSezbIH1w9jWKiELAtwhd65uwT5pyi8=; b=r0fDhiWazxVDdkE4Z25aNVl5bdzaYleT4LQCRNLK8fUp+AK7514yIDDSE8Mg8NyCsZ xeCCAsO66e3gQucF93YjhcYEVry4EbOZ7a1HTGEemGGs9IJv12cGBNLKVjzpZRMTiW/e 3S2RDkbuxW8EShCKYZZ5564zypqKajqXvOSYEBRpWB63B9YRKcahbiRBST6HHEjiEBP6 xHst15tf8WCRZ2u9txvuB14SeXn6LnDIqHmXTzpCYjK6ncuh1AwjgdIn/BM8W13Si4I3 AHvaU3jhim7H7icXtbNbN07WesTly76x2V2hPOQ39ESyZPyhqato7QGD2vY61MCrTzCK K2hw== X-Gm-Message-State: APjAAAW558lixzy82WyVhWiPTiaTjOrCQlTv7Q+n/O2dFi96zzXqbZ19 OvE30v4DCws/jEUT+zhouJtmnOO0er2wphn4 X-Google-Smtp-Source: APXvYqxkUgniTzQJg8gPyM6kI1+fs0llEQlDUqb6MZg/LlzB8qbQRTAoiGpSyBRUZz0o5q8yAv1F9w== X-Received: by 2002:a1c:9950:: with SMTP id b77mr4989384wme.46.1566378852589; Wed, 21 Aug 2019 02:14:12 -0700 (PDT) Received: from localhost.localdomain (ipbcc0f857.dynamic.kabel-deutschland.de. [188.192.248.87]) by smtp.gmail.com with ESMTPSA id o14sm37173171wrg.64.2019.08.21.02.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2019 02:14:12 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 21 Aug 2019 11:04:38 +0200 Message-Id: <20190821090438.10260-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190821090438.10260-1-andreas.rheinhardt@gmail.com> References: <20190821090438.10260-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/wtvdec: Forward errors when reading packet 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" wtvfile_read_packet did not abide by the requirements of a function destined to read a packet: If it did not read anything, it returned zero, which currently leads to a warning in read_packet_wrapper in aviobuf.c. Said warning will be an av_assert2 as soon as FF_API_OLD_AVIO_EOF_0 is zero (probably the next major version bump). So instead forward the error code from the underlying protocol; if this was never ever called or returned zero, return AVERROR_EOF as read_packet_wrapper currently does. This error/assert is triggered in the wtv-demux FATE test. Signed-off-by: Andreas Rheinhardt --- I am not sure what the right approach is if nread and n are both zero. Is it actually allowed for the buf_size argument to be zero? (In this case, this scenario would happen.) libavformat/wtvdec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 706e8ca38d..56c54f6aba 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -71,7 +71,7 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size) { WtvFile *wf = opaque; AVIOContext *pb = wf->pb_filesystem; - int nread = 0; + int nread = 0, n = 0; if (wf->error || pb->error) return -1; @@ -80,7 +80,6 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size) buf_size = FFMIN(buf_size, wf->length - wf->position); while(nread < buf_size) { - int n; int remaining_in_sector = (1 << wf->sector_bits) - (wf->position & ((1 << wf->sector_bits) - 1)); int read_request = FFMIN(buf_size - nread, remaining_in_sector); @@ -100,7 +99,7 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size) } } } - return nread; + return nread ? nread : n ? n : AVERROR_EOF; } /**