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 A0EA647E1D for ; Mon, 27 Nov 2023 14:10:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DF9F668CEEA; Mon, 27 Nov 2023 16:10:22 +0200 (EET) Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA9F968CC52 for ; Mon, 27 Nov 2023 16:10:13 +0200 (EET) Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-67a218d702aso6729996d6.1 for ; Mon, 27 Nov 2023 06:10:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701094212; x=1701699012; 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=fH8HYKiNPHW7ZDSGyfGcJ/FUPryx9mYw/TOXRuJxGYxk+qlWdbkIslXIkgZ4cVOIJ+ g4imZfYatkdxSpyCOt2BV6GbgnFEjxSgM3/P+31oM6COaGhbafHeGB4FHQPq3FJ4Pznm 9M51dZyiakZymlZaD1QBcdDTdVUs/6fe/kx6foFUZajUaqA5T1Iof4yUSXDHexxqyx5f mu81sJPqtEAGnv57PbiDt1yOCJwx4h8hOT8rpCsQRBmzw+SlSsYUR97L0biT9GVe1kfl YSfW1IL/hg3KlwIhWWYWPE65DYle2hQkxltFCWPdoC4ramPSsmyIyiGYmvut7gI5PjYW DZwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094212; x=1701699012; 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=jqsqtjDFhHuOolzswnyjtTnrCVjVucYBfTCbXmmoV5/vqnL0L/RRQ8n0RLM0JN0G48 ATPqolCv9uqibkgDQZDXfDG1gY1ztMU6MddZ5TgYNKfFZhP2Wo66lsHwiyS42GPs5NYg CYxJLTtv7upQ6f3BXgzKzOIAqlj6fexvBOlJeyg3DRl27iHbuvCwNBoFdGqX7y/NQbZ1 CjjXp46C35xbcpaSNik/h09AbCEqt6q9Ib2Ci5VB/cRe+Yw3MqZTA+S715IgX7oIE993 WNTJ9wu3GqRWxxFVSgNikGhsiQ6OFuDVFBMu9KCKPbwOCGZz0b/4V9n2X9X7dOdEdh5q k3Wg== X-Gm-Message-State: AOJu0YzUCq+GtHx+erDZ0pgl321pfv37oykqZ4zQVq4OfrnXWiXRNELs /wykPAyicjhU6vNe4M0/Ejbiafdb2/o= X-Google-Smtp-Source: AGHT+IHyseOQ0Ye5lRMuxjqNWZ0OHx+mBY8MGuTVlewXgZwuNikrWP+Fc2TSwl1joj1O0IrI/5kb7g== X-Received: by 2002:ad4:4982:0:b0:67a:14fe:f3b0 with SMTP id u2-20020ad44982000000b0067a14fef3b0mr11142499qvx.0.1701094212553; Mon, 27 Nov 2023 06:10:12 -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 tp13-20020a05620a3c8d00b0077d72f820adsm3699365qkn.115.2023.11.27.06.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:10:12 -0800 (PST) From: Leo Izen To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Nov 2023 09:10:06 -0500 Message-ID: <20231127141008.183621-2-leo.izen@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231127141008.183621-1-leo.izen@gmail.com> References: <20231127141008.183621-1-leo.izen@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/3] 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".