From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id C1C344DCFB
	for <ffmpegdev@gitmailbox.com>; Thu, 24 Apr 2025 03:08:36 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CAD69687FCC;
	Thu, 24 Apr 2025 06:08:31 +0300 (EEST)
Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com
 [209.85.128.53])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6B60B687ACB
 for <ffmpeg-devel@ffmpeg.org>; Thu, 24 Apr 2025 06:08:24 +0300 (EEST)
Received: by mail-wm1-f53.google.com with SMTP id
 5b1f17b1804b1-43cf0d787eeso5313465e9.3
 for <ffmpeg-devel@ffmpeg.org>; Wed, 23 Apr 2025 20:08:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1745464103; x=1746068903; darn=ffmpeg.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:to:from:from:to:cc:subject:date:message-id
 :reply-to; bh=L/XToBHMNinUHHLJ4bG0bB7ZVedbR3vBD1e+3xaRptA=;
 b=TfbjtYCy1AmD91lw1xO8IECZ9mmnTOg5dw5xyGXS+OW88Y0E4442AvnjbOTfR/OXxp
 XJCFTzHBKm6sthoQ63Oo2bv0gsFYCXlkRpFAtdAJw4rdhVa25N7OKAp/cSZivB/uPXSv
 TaWFetuIzbh/GBvXzY2nUBl6ieKE/wDUBw2babcmBlL395b3fcjqwB8t6swVvYEMsr6t
 jCHMQrD/Ysv0hc/VxMquJHeOvAAHVTUiiZrViDLcapQYhC3H26C8Y3Ccw5LEG7x0KkTq
 Z5ziuxIBNftUG8RpjOHd65J7Gl/4qRelpqYFRRsAreALGWx23voDLD3oKVN3kIIFT9+u
 gyBA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1745464103; x=1746068903;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=L/XToBHMNinUHHLJ4bG0bB7ZVedbR3vBD1e+3xaRptA=;
 b=FlZRFcSfQVHwjlnCDuQuRj4wcFBHFaERNlhwXANfnkA50/xcM9SRgorab9HtcS+xE7
 tTZOED4+Aj9ythAQ0Y3Rq/DI7xfci1ThdQLaVAhSpA+6hdWS7PmawiYugnp9V/iuiDHz
 VWkH4Z2L9myQcTtg37hLFP9L8VqnvgdWGD2bxiYDljb9EBm2ldP7Efq+tO+EQvzRbSYK
 eNU0Uxr6GwqXWpccre6NlQpQi3hpPQf6VuHXv6ZdxyxgE4wcfBSOfFHIEYpAM60Imqhh
 1J1KltVdTYnHyiYGim638U4e/md/mLg87ZgCsI/QZSZdgkIwusXA3p7fWuV8MlAqCP5J
 Dhbg==
X-Gm-Message-State: AOJu0YwhQ9reRz+t1d6Sd0/jocNHKsTxs3OfmwckaFFwOTDrLbz/F3M+
 EzNUpQg/vG8QGHducs0fp9PwiI472w1ljuk22CcvNPhmGXtQL/9QqK5M1A==
X-Gm-Gg: ASbGncuOpEeo4MFi1bJYRPI0xjwSroRIiV7RoVBgMGDdTyjG8c2lNAvlFsSGa9cLJM9
 aKvhhTiQ27Iw3Yo69brdgqbcLTdTWhUDafm25rhTrMU96yAO7pXBRn89K4g1Ah+gr46UIPuEbR8
 xm1R1PTWy3K1kTIrs7hNG9OEfL6xanczcD1KMmhD5E3d6klnV+v3opBozvbZ2DckZdydY8E2nLI
 KXUBUZgHUk9+D6DjjtaElTj84sU2gYLTxaSNVMij8fXT7kD4TWTKEqPGQEw0mqLDMk4c7E6Gvpv
 2AX3gTq0WzgXP5EKrlVq2wwCLpggfT6e2HmczAHmvaj+6IwDU6+EQl5gO2F524j6PfPWo9MTVqo
 F+OhniWuBX6Iez/7x+FzswclMIBJRLWz4KlFfB5gXOQzi3XY3Sx1iuBPDKA==
X-Google-Smtp-Source: AGHT+IF/n3rAoH+OEc9m5B1Qq5U9IS46TPZNu6M38NFj2hp4FmcLgMmgFW5+hLLQabPCd9hZE8XaLQ==
X-Received: by 2002:a05:600c:1387:b0:43c:fe5e:f03b with SMTP id
 5b1f17b1804b1-4409bdaf733mr6350715e9.30.1745464103350; 
 Wed, 23 Apr 2025 20:08:23 -0700 (PDT)
Received: from [192.168.178.57]
 (p200300cccf18bd008044ec081157f983.dip0.t-ipconnect.de.
 [2003:cc:cf18:bd00:8044:ec08:1157:f983])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4409d2a2eabsm2973645e9.12.2025.04.23.20.08.22
 for <ffmpeg-devel@ffmpeg.org>
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 23 Apr 2025 20:08:22 -0700 (PDT)
From: Marvin Scholz <epirat07@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Date: Thu, 24 Apr 2025 05:08:22 +0200
X-Mailer: MailMate (2.0r6222)
Message-ID: <108CDCB6-9027-4188-8D96-4C1F11953F4B@gmail.com>
In-Reply-To: <tencent_FCCD17A003CDE7CFD35572A73038C6961A07@qq.com>
References: <tencent_FCCD17A003CDE7CFD35572A73038C6961A07@qq.com>
MIME-Version: 1.0
Subject: Re: [FFmpeg-devel] [PATCH 2/3] avformat/hls: Show error info when
 read key file failed
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/108CDCB6-9027-4188-8D96-4C1F11953F4B@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>



On 23 Apr 2025, at 14:59, Zhao Zhili wrote:

> From: Zhao Zhili <zhilizhao@tencent.com>
>
> ---
>  libavformat/hls.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 6623c80309..45c1b283c9 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -1353,16 +1353,18 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg,
>      if (seg->key_type == KEY_AES_128 || seg->key_type == KEY_SAMPLE_AES) {
>          if (strcmp(seg->key, pls->key_url)) {
>              AVIOContext *pb = NULL;
> -            if (open_url(pls->parent, &pb, seg->key, &c->avio_opts, NULL, NULL) == 0) {
> +
> +            ret = open_url(pls->parent, &pb, seg->key, &c->avio_opts, NULL, NULL);
> +            if (ret >= 0) {
>                  ret = avio_read(pb, pls->key, sizeof(pls->key));
>                  if (ret != sizeof(pls->key)) {
> -                    av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s\n",
> -                           seg->key);
> +                    av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s, %s\n",
> +                           seg->key, av_err2str(ret));

The check here is just checking if the size matches the expected size, lets say it just
reads 1 byte instead if 10, av_err2str(ret) called with 1 in this example wont give you
anything meaningful and even more unhelpful than the previous message.

You should check that ret is actually negative, else you should probably report that the file
ended unexpectedly, printing the expected size and amount that was actually read.

(Also unrelated to this patch but this ret is eventually returned by the function with a possibly
positive value in this case which seems wrong...)

>                  }
>                  ff_format_io_close(pls->parent, &pb);
>              } else {
> -                av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s\n",
> -                       seg->key);
> +                av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s, %s\n",
> +                       seg->key, av_err2str(ret));
>              }
>              av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url));
>          }
> -- 
> 2.46.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".