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 207B748302 for ; Thu, 23 Nov 2023 23:45:56 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 25A7768CC91; Fri, 24 Nov 2023 01:45:53 +0200 (EET) Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 13C6D68CB87 for ; Fri, 24 Nov 2023 01:45:46 +0200 (EET) Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-779d0c05959so16078685a.1 for ; Thu, 23 Nov 2023 15:45:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700783145; x=1701387945; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yI5vuTzgvGu5HmcVrYfSeJvc+FG68GcBjqNNCg+eAIE=; b=A76tqpkSU2IQSmJCKSZUmYj1QyCJ1VrytfF0dVEQ7Ed6ixcHL+oXxO088MAhhfHosU 8QtCErIlyLu5Iatn+cZl8iAcuQBYo3DvEeVz/xpGhu0fNC+Y8vefJUIts7IRw0Qbplqg EoydFcEJU1pONbqsdvLZP2Y5TP8hb5txhggMoq2A3uUV0ARXofNeVIgu8GG+Lg8LZ4XQ rIHI83CLkig7rNoIe3cn6k/WzH4UkWyL7I/INWTC113SHgcBfAoYngQCCfp+fO/Pn3iH ziiYq9vvcHqstM85iXIgrS2n100Qf8UFB87S3Ir9iH7OIe4SpuKEsArFFIExPYPdrhee dPFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700783145; x=1701387945; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yI5vuTzgvGu5HmcVrYfSeJvc+FG68GcBjqNNCg+eAIE=; b=NPH2si9dbm/+CNhLrvkQ8azVD07tYGYmJJP7vwWEtleYuPkHQ4nKLBEnqmil4bL104 106wkLDYb+K1jM4AdKyau2gDAvp6f4thWdQqD4ufYjZ2ElBjfHCghnD1LNPrpuN74WJB EmOjCrALompWbrG1XQ8DiAfaOGjwPKvaMnTr0kW/m0UuOqSMSy4BxcjVri5unzfAUdQb 6df98J13Jbkyw5F/dI57PCIpJG5XRt8tkDh98YZSxZKZWX6SLoJN5tU3mHKNtci/E0ow 1dMHvkwJE1PZm3k1g/WP7Sk4ZEVfwSxeDwlvpwIEX8hr2e9fde8RP80AHn11YoSLZch0 oQ3g== X-Gm-Message-State: AOJu0YweQNMgBvoE3uQVNFjScX8Wmno4bnmNOL1avK94yOBDJfIT48rk 4075V7QcpgHYny1aDwTYhe0g8IlTkK4= X-Google-Smtp-Source: AGHT+IHHYb0RZz3IgTcNFAKWrP1ZhTgPI2VM/RvK4uT68Gh8D6602TWC/kbvXVr+i0YzxhFxhVeWOw== X-Received: by 2002:a05:6214:e62:b0:679:dfc4:a5b with SMTP id jz2-20020a0562140e6200b00679dfc40a5bmr1107121qvb.5.1700783144620; Thu, 23 Nov 2023 15:45:44 -0800 (PST) Received: from gauss.local (c-68-56-149-176.hsd1.mi.comcast.net. [68.56.149.176]) by smtp.gmail.com with ESMTPSA id dy20-20020ad44e94000000b0067a14f54f8asm110601qvb.50.2023.11.23.15.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 15:45:44 -0800 (PST) From: Leo Izen To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Nov 2023 18:45:40 -0500 Message-ID: <20231123234541.41316-2-leo.izen@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231123234541.41316-1-leo.izen@gmail.com> References: <20231123234541.41316-1-leo.izen@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/jpegxl_parse{, r}: use correct ISOBMFF extended size location 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 Cc: Leo Izen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: According to ISO/IEC 14996-12, size == 1 means a 64-bit extended-size field occurs *after* the 32-bit box type, not before. This fix should allow correct parsing of JXL files with extended-size boxes. Signed-off-by: Leo Izen --- libavcodec/jpegxl_parse.c | 6 +++--- libavcodec/jpegxl_parser.c | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/jpegxl_parse.c b/libavcodec/jpegxl_parse.c index eb28e80867..7cfdd3e7d5 100644 --- a/libavcodec/jpegxl_parse.c +++ b/libavcodec/jpegxl_parse.c @@ -462,8 +462,10 @@ int ff_jpegxl_collect_codestream_header(const uint8_t *input_buffer, int input_l return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be32(&gb); + tag = bytestream2_get_le32(&gb); + if (size == 1) { - if (bytestream2_get_bytes_left(&gb) < 12) + if (bytestream2_get_bytes_left(&gb) < 8) return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be64(&gb); head_size = 16; @@ -474,8 +476,6 @@ int ff_jpegxl_collect_codestream_header(const uint8_t *input_buffer, int input_l if (size) size -= head_size; - tag = bytestream2_get_le32(&gb); - if (tag == MKTAG('j','x','l','p')) { uint32_t idx; if (bytestream2_get_bytes_left(&gb) < 4) diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c index 630fc8a60b..750872f17f 100644 --- a/libavcodec/jpegxl_parser.c +++ b/libavcodec/jpegxl_parser.c @@ -1342,7 +1342,7 @@ static int skip_boxes(JXLParseContext *ctx, const uint8_t *buf, int buf_size) while (1) { uint64_t size; - int head_size = 4; + int head_size = 8; if (bytestream2_peek_le16(&gb) == FF_JPEGXL_CODESTREAM_SIGNATURE_LE) break; @@ -1353,16 +1353,17 @@ static int skip_boxes(JXLParseContext *ctx, const uint8_t *buf, int buf_size) return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be32(&gb); + bytestream2_skip(&gb, 4); // tag if (size == 1) { - if (bytestream2_get_bytes_left(&gb) < 12) + if (bytestream2_get_bytes_left(&gb) < 8) return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be64(&gb); - head_size = 12; + head_size = 16; } if (!size) return AVERROR_INVALIDDATA; /* invalid ISOBMFF size */ - if (size <= head_size + 4 || size > INT_MAX - ctx->skip) + if (size <= head_size || size > INT_MAX - ctx->skip) return AVERROR_INVALIDDATA; ctx->skip += size; -- 2.43.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".