From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by master.gitmailbox.com (Postfix) with ESMTPS id B6F0C406C5 for ; Wed, 22 Dec 2021 15:03:39 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id t19so2613737pfg.9 for ; Wed, 22 Dec 2021 07:03:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=1P2Ib9NUU7F14S+HO8PKTEivp2iOE4j0B1hkj1TxUJ8=; b=dn9k0dFvw+iDo6/+D6o2TNdJ45RpNkdyH+nPzBirTrsrXJshriUwS+Hcoc+/Q96SRB lf/8dhAxrCCOtHYxT76tIqGgg3X4nAjIJWFx35f7YMsyVPcMor9qI+R6RMg9nnZ6M1d7 0Ij/qUjFaQz/VqSGJUYT9l9lG+zOw8AWcpOyVZSncgiSbw8ZesNekXlwUdHi9XPMh+GY xggu1b4sW9XBPt8x9JfVHxwgDMkmG6jYF+KsVeLsGPpcUCDDSsf/4sQXibE+yzRjHLFQ 44wKtC2Za9n9OhklWY3fQaRJkGWDf4xP2JPhaHB0ejJcw4CtHyFPEb3lU2aDBQz3BxFs oi3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=1P2Ib9NUU7F14S+HO8PKTEivp2iOE4j0B1hkj1TxUJ8=; b=bpIx1GCU89zdKC6XwX2cEgtdrrHgbs6D7ZtM5bU19w9r/qvthEetcAocOFmXf0ywca 3O2WlExJrGW7kfcVrC4SndIDp76jLnTi5sPilQoLSehta1y2JZCNhVER23R+SN6uIfoe hViI/cUFjNJ3/o5ySk72VAGPrOxecR62O62fB67nOM46F1s4aguN7rUJ2/ehSBrMxFC+ ElVySEoXx8uU2AktmNVAfcioUcu4eAtSkK+jHqk2hpC/rheJrp7z/J3GCBJXhhm4yozB sgc6zGb0hyEQBgm2gktArx2xeDIcj6p7MJpxHtREAIfE11i9eMFF0YaFdm3ORl8f/5au xrIw== X-Gm-Message-State: AOAM530ecyGqWgfn4RfQScxy6c8CaL5Nrq2QVVl5NHfjzBm7XAD44wpr 5LWdhbEwAzirZT5nxYYXPkMIvDAyRJsxRH1d X-Google-Smtp-Source: ABdhPJygPgokP8fq+fIq1Tv0ICZNQXidOlq9zwc984+DwJClA+0tI1vJrTwQ8RWzQW3B/AabYO0xqw== X-Received: by 2002:a17:902:db02:b0:149:4600:babc with SMTP id m2-20020a170902db0200b001494600babcmr997468plx.2.1640183589724; Wed, 22 Dec 2021 06:33:09 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id pc1sm7165014pjb.5.2021.12.22.06.33.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Dec 2021 06:33:09 -0800 (PST) Message-Id: <55b554ce2316dc8953a16e17b6897abd96d996b2.1640183587.git.ffmpegagent@gmail.com> In-Reply-To: References: From: ffmpegagent Date: Wed, 22 Dec 2021 14:32:57 +0000 Subject: [PATCH 01/11] libavformat/asf: fix handling of byte array length values Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: ffmpegdev@gitmailbox.com Cc: softworkz , softworkz Archived-At: List-Archive: List-Post: From: softworkz The spec allows attachment sizes of up to UINT32_MAX while we can handle only sizes up to INT32_MAX (in downstream code). The debug.assert in get_tag didn't really address this, and truncating the value_len in calling methods cannot be used because the length value is required in order to continue parsing. This adds a check with log message in ff_asf_handle_byte_array to handle those (rare) cases. Signed-off-by: softworkz --- libavformat/asf.c | 12 +++++++++--- libavformat/asf.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libavformat/asf.c b/libavformat/asf.c index 1ac8b5f078..179b66a2b4 100644 --- a/libavformat/asf.c +++ b/libavformat/asf.c @@ -267,12 +267,18 @@ static int get_id3_tag(AVFormatContext *s, int len) } int ff_asf_handle_byte_array(AVFormatContext *s, const char *name, - int val_len) + uint32_t val_len) { + if (val_len > INT32_MAX) { + av_log(s, AV_LOG_VERBOSE, "Unable to handle byte arrays > INT32_MAX in tag %s.\n", name); + return 1; + } + if (!strcmp(name, "WM/Picture")) // handle cover art - return asf_read_picture(s, val_len); + return asf_read_picture(s, (int)val_len); else if (!strcmp(name, "ID3")) // handle ID3 tag - return get_id3_tag(s, val_len); + return get_id3_tag(s, (int)val_len); + av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", name); return 1; } diff --git a/libavformat/asf.h b/libavformat/asf.h index 01cc4f7a46..4d28560f56 100644 --- a/libavformat/asf.h +++ b/libavformat/asf.h @@ -111,7 +111,7 @@ extern const AVMetadataConv ff_asf_metadata_conv[]; * is unsupported by this function and 0 otherwise. */ int ff_asf_handle_byte_array(AVFormatContext *s, const char *name, - int val_len); + uint32_t val_len); #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 0000 -- gitgitgadget