public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/bzip3] epel8: Stricter checks at boundaries for bz3_decode and CLI
Date: Fri, 23 Oct 2026 11:58:02 GMT [thread overview]
Message-ID: <179275668274.1.4968120079740744127.rpms-bzip3-c56e154efd23@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/bzip3
Branch : epel8
Commit : c56e154efd23a57a4e49ef2cb5de68852b70f801
Author : Petr Písař <ppisar@redhat.com>
Date : 2026-10-23T13:57:46+02:00
Stats : +110/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/bzip3/c/c56e154efd23a57a4e49ef2cb5de68852b70f801?branch=epel8
Log:
Stricter checks at boundaries for bz3_decode and CLI
---
diff --git a/bzip3-1.3.1-stricter-checks-at-boundaries-for-bz3_decode-and-cli.patch b/bzip3-1.3.1-stricter-checks-at-boundaries-for-bz3_decode-and-cli.patch
new file mode 100644
index 0000000..8fd036d
--- /dev/null
+++ b/bzip3-1.3.1-stricter-checks-at-boundaries-for-bz3_decode-and-cli.patch
@@ -0,0 +1,103 @@
+From ae663430fb291c464c6f1111540e53cde71419c1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
+Date: Fri, 23 Oct 2026 11:16:58 +0200
+Subject: [PATCH] stricter checks at boundaries for bz3_decode and cli
+
+Upstream commit: dce3573ac49837040f9b8c44c051f15162ac6a7a
+Petr Pisar: Ported to 1.3.1
+---
+ src/libbz3.c | 11 +++++++++--
+ src/main.c | 13 +++++++++----
+ 2 files changed, 18 insertions(+), 6 deletions(-)
+
+diff --git a/src/libbz3.c b/src/libbz3.c
+index a66a766..25ad329 100644
+--- a/src/libbz3.c
++++ b/src/libbz3.c
+@@ -626,6 +626,12 @@ BZIP3_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_s
+ return -1;
+ }
+
++ // The original size can never exceed the block size, regardless of the block type.
++ if (orig_size > state->block_size || orig_size < 0) {
++ state->last_error = BZ3_ERR_MALFORMED_HEADER;
++ return -1;
++ }
++
+ if (bwt_idx == -1) {
+ if (data_size - 8 > 64 || data_size < 8) {
+ state->last_error = BZ3_ERR_MALFORMED_HEADER;
+@@ -719,7 +725,8 @@ BZIP3_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_s
+
+ state->last_error = BZ3_OK;
+
+- if (size_src > state->block_size || size_src < 0) {
++ // Callers rely on orig_size bytes of `buffer' being initialised with decoded data.
++ if (size_src > state->block_size || size_src < 0 || size_src != orig_size) {
+ state->last_error = BZ3_ERR_MALFORMED_HEADER;
+ return -1;
+ }
+@@ -892,7 +899,7 @@ BZIP3_API int bz3_decompress(const uint8_t * in, uint8_t * out, size_t in_size,
+ return BZ3_ERR_TRUNCATED_DATA;
+ }
+ s32 orig_size = read_neutral_s32(in + 4);
+- if (orig_size < 0) goto malformed_header;
++ if (orig_size < 0 || orig_size > (s32)block_size) goto malformed_header;
+ if (buf_max < *out_size + orig_size) {
+ bz3_free(state);
+ free(compression_buf);
+diff --git a/src/main.c b/src/main.c
+index fa1a9e4..9bce7b0 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -114,6 +114,11 @@ static void xread_noeof(void * data, size_t size, size_t len, FILE * des) {
+ }
+ }
+
++/* Validate the compressed and original sizes stored in a block header. */
++static int valid_block_header(s32 new_size, s32 old_size, s32 block_size) {
++ return new_size >= 0 && (size_t)new_size <= bz3_bound(block_size) && old_size >= 0 && old_size <= block_size;
++}
++
+ static void close_out_file(FILE * des) {
+ if (des) {
+ int outfd = fileno(des);
+@@ -244,7 +249,7 @@ static int process(FILE * input_des, FILE * output_des, int mode, int block_size
+ new_size = read_neutral_s32(byteswap_buf);
+ xread_noeof(&byteswap_buf, 1, 4, input_des);
+ old_size = read_neutral_s32(byteswap_buf);
+- if (old_size > bz3_bound(block_size) || new_size > bz3_bound(block_size)) {
++ if (!valid_block_header(new_size, old_size, block_size)) {
+ fprintf(stderr, "Failed to decode a block: Inconsistent headers.\n");
+ return 1;
+ }
+@@ -265,7 +270,7 @@ static int process(FILE * input_des, FILE * output_des, int mode, int block_size
+ new_size = read_neutral_s32(byteswap_buf);
+ xread_noeof(&byteswap_buf, 1, 4, input_des);
+ old_size = read_neutral_s32(byteswap_buf);
+- if (old_size > bz3_bound(block_size) || new_size > bz3_bound(block_size)) {
++ if (!valid_block_header(new_size, old_size, block_size)) {
+ fprintf(stderr, "Failed to decode a block: Inconsistent headers.\n");
+ return 1;
+ }
+@@ -343,7 +348,7 @@ static int process(FILE * input_des, FILE * output_des, int mode, int block_size
+ sizes[i] = read_neutral_s32(byteswap_buf);
+ xread_noeof(&byteswap_buf, 1, 4, input_des);
+ old_sizes[i] = read_neutral_s32(byteswap_buf);
+- if (old_sizes[i] > bz3_bound(block_size) || sizes[i] > bz3_bound(block_size)) {
++ if (!valid_block_header(sizes[i], old_sizes[i], block_size)) {
+ fprintf(stderr, "Failed to decode a block: Inconsistent headers.\n");
+ return 1;
+ }
+@@ -371,7 +376,7 @@ static int process(FILE * input_des, FILE * output_des, int mode, int block_size
+ sizes[i] = read_neutral_s32(byteswap_buf);
+ xread_noeof(&byteswap_buf, 1, 4, input_des);
+ old_sizes[i] = read_neutral_s32(byteswap_buf);
+- if (old_sizes[i] > bz3_bound(block_size) || sizes[i] > bz3_bound(block_size)) {
++ if (!valid_block_header(sizes[i], old_sizes[i], block_size)) {
+ fprintf(stderr, "Failed to decode a block: Inconsistent headers.\n");
+ return 1;
+ }
+--
+2.56.0
+
diff --git a/bzip3.spec b/bzip3.spec
index d33bd31..4d936a9 100644
--- a/bzip3.spec
+++ b/bzip3.spec
@@ -1,6 +1,6 @@
Name: bzip3
Version: 1.3.1
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: Tools for compressing and decompressing bzip3 files
# bz3grep: BSD-2-Clause
# include/common.h: LGPL-3.0-or-later
@@ -66,6 +66,9 @@ Patch8: bzip3-1.5.3-fix-174.patch
# in upstream after 1.5.3,
# <https://github.com/iczelia/bzip3/issues/175>
Patch9: bzip3-1.5.3-fix-175.patch
+# Stricter checks at boundaries for bz3_decode and CLI,
+# in upstream after 1.5.4
+Patch10: bzip3-1.3.1-stricter-checks-at-boundaries-for-bz3_decode-and-cli.patch
BuildRequires: autoconf
BuildRequires: autoconf-archive
BuildRequires: automake
@@ -187,6 +190,9 @@ fi
%{_libdir}/pkgconfig/bzip3.pc
%changelog
+* Fri Oct 23 2026 Petr Pisar <ppisar@redhat.com> - 1.3.1-6
+- Stricter checks at boundaries for bz3_decode and CLI
+
* Tue Sep 08 2026 Petr Pisar <ppisar@redhat.com> - 1.3.1-5
- Fix decompressing large incompressible streams (upstream GH#174)
- Fix compressing streams of size being a multiple of bzip3 stream block size
reply other threads:[~2026-10-23 11:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179275668274.1.4968120079740744127.rpms-bzip3-c56e154efd23@fedoraproject.org \
--to=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox