From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4A4D84A73F for ; Sun, 5 May 2024 19:45:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1484068D569; Sun, 5 May 2024 22:45:47 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5303768D53C for ; Sun, 5 May 2024 22:45:41 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id ED0E9EA59A for ; Sun, 5 May 2024 21:45:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CgaNJjXVhfAO for ; Sun, 5 May 2024 21:45:38 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 42D5AEA599 for ; Sun, 5 May 2024 21:45:38 +0200 (CEST) Date: Sun, 5 May 2024 21:45:38 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <68592f88-f5ca-4626-a1dc-e40d6f6cedf8@uplex.de> Message-ID: References: <68592f88-f5ca-4626-a1dc-e40d6f6cedf8@uplex.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="467242196-1417122619-1714938338=:24520" Subject: Re: [FFmpeg-devel] [PATCH] avformat/file: fail for non-numerical arguments to pipe: X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" Archived-At: List-Archive: List-Post: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --467242196-1417122619-1714938338=:24520 Content-Type: text/plain; charset=US-ASCII; format=flowed On Mon, 29 Apr 2024, Nils Goroll wrote: > Before this patch, the implementation of pipe: inputs/outputs would > silently fall back to stdin/stdout for any argument not successfully > parsed by strtol(). > > This patch introduces an explicit error for any non-numerical arguments, > which should avoid user confusion as in #10977. > > New behavior: > > $ cat /tmp/video.mkv | ./ffmpeg -i pipe:aa -acodec copy -vcodec copy -f > matroska pipe:1 | cat >/tmp/out.mkv > > [pipe @ 0x5618c7bcf740] Non-numerical argument "aa" to pipe: > [in#0 @ 0x5618c7bced00] Error opening input: Invalid argument > Error opening input file pipe:aa. > Error opening input files: Invalid argument OK in principle, but the patch is a bit overcomplicated and is mixing cosmetic and functional changes. See a simplifed version attached, will apply that in a few days. Thanks, Marton > > Signed-off-by: Nils Goroll > --- > libavformat/file.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/libavformat/file.c b/libavformat/file.c > index 0b7452bc20..317a769e32 100644 > --- a/libavformat/file.c > +++ b/libavformat/file.c > @@ -437,18 +437,21 @@ static int pipe_open(URLContext *h, const char > *filename, int flags) > { > FileContext *c = h->priv_data; > int fd; > - char *final; > + char *final = NULL; > if (c->fd < 0) { > av_strstart(filename, "pipe:", &filename); > - fd = strtol(filename, &final, 10); > - if((filename == final) || *final ) {/* No digits found, or something > like 10ab */ > - if (flags & AVIO_FLAG_WRITE) { > - fd = 1; > - } else { > - fd = 0; > - } > + if (*filename == '\0') > + fd = (flags & AVIO_FLAG_WRITE) ? 1 : 0; > + else > + fd = strtol(filename, &final, 10); > + > + if (final != NULL && *final != '\0') { > + av_log(h, AV_LOG_ERROR, > + "Non-numerical argument \"%s\" to pipe:\n", > + filename); > + return AVERROR(EINVAL); > } > c->fd = fd; > } > -- > 2.39.2 > > _______________________________________________ > 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". > > --467242196-1417122619-1714938338=:24520 Content-Type: text/x-patch; name=0001-avformat-file-fail-for-non-numerical-arguments-to-pi.patch Content-Transfer-Encoding: BASE64 Content-ID: <5723f7ed-703a-3e93-f0b8-c7daac1a86b2@passwd.hu> Content-Description: Content-Disposition: attachment; filename=0001-avformat-file-fail-for-non-numerical-arguments-to-pi.patch RnJvbSAxZTY1YWE5ZTE0Y2M2NmFjYzUwNmJjN2Y0MTkwM2E3NjYyNzMyN2Y3 IE1vbiBTZXAgMTcgMDA6MDA6MDAgMjAwMQ0KRnJvbTogTWFydG9uIEJhbGlu dCA8Y3VzQHBhc3N3ZC5odT4NCkRhdGU6IFN1biwgNSBNYXkgMjAyNCAyMToz MTo0NyArMDIwMA0KU3ViamVjdDogW1BBVENIXSBhdmZvcm1hdC9maWxlOiBm YWlsIGZvciBub24tbnVtZXJpY2FsIGFyZ3VtZW50cyB0byBwaXBlOg0KDQpC ZWZvcmUgdGhpcyBwYXRjaCwgdGhlIGltcGxlbWVudGF0aW9uIG9mIHBpcGU6 IGlucHV0cy9vdXRwdXRzIHdvdWxkDQpzaWxlbnRseSBmYWxsIGJhY2sgdG8g c3RkaW4vc3Rkb3V0IGZvciBhbnkgYXJndW1lbnQgbm90IHN1Y2Nlc3NmdWxs eQ0KcGFyc2VkIGJ5IHN0cnRvbCgpLg0KDQpUaGlzIHBhdGNoIGludHJvZHVj ZXMgYW4gZXhwbGljaXQgZXJyb3IgZm9yIGFueSBub24tbnVtZXJpY2FsIGFy Z3VtZW50cywNCndoaWNoIHNob3VsZCBhdm9pZCB1c2VyIGNvbmZ1c2lvbiBh cyBpbiAjMTA5NzcuDQoNCk5ldyBiZWhhdmlvcjoNCg0KJCBjYXQgL3RtcC92 aWRlby5ta3YgfCAuL2ZmbXBlZyAtaSBwaX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kID0gc3RydG9sKGZpbGVuYW1lLCAmZmluYWws IDEwKTsNCi0gICAgICAgIGlmKChmaWxlbmFtZSA9PSBmaW5hbCkgfHwgKmZp bmFsICkgey8qIE5vIGRpZ2l0cyBmb3VuZCwgb3Igc29tZXRoaW5nIGxpa2Ug MTBhYiAqLw0KKyAgICAgICAgaWYgKCEqZmlsZW5hbWUpIHsNCiAgICAgICAg ICAgICBpZiAoZmxhZ3MgJiBBVklPX0ZMQUdfV1JJVEUpIHsNCiAgICAgICAg ICAgICAgICAgZmQgPSAxOw0KICAgICAgICAgICAgIH0gZWxzZSB7DQogICAg ICAgICAgICAgICAgIGZkID0gMDsNCiAgICAgICAgICAgICB9DQorICAgICAg ICB9IGVsc2Ugew0KKyAgICAgICAgICAgIGZkID0gc3RydG9sKGZpbGVuYW1l LCAmZmluYWwsIDEwKTsNCisgICAgICAgICAgICBpZiAoKmZpbmFsKSAvKiBO byBkaWdpdHMgZm91bmQsIG9yIHNvbWV0aGluZyBsaWtlIDEwYWIgKi8NCisg ICAgICAgICAgICAgICAgcmV0dXJuIEFWRVJST1IoRUlOVkFMKTsNCiAgICAg ICAgIH0NCiAgICAgICAgIGMtPmZkID0gZmQ7DQogICAgIH0NCi0tIA0KMi4z NS4zDQoNCg== --467242196-1417122619-1714938338=:24520 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --467242196-1417122619-1714938338=:24520--