public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Gwyn Ciesla <gwync@protonmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/python-dulwich] f44: Patch for test failure
Date: Wed, 11 Nov 2026 18:35:13 GMT	[thread overview]
Message-ID: <179442211384.1.8466824432227101676.rpms-python-dulwich-c449203152d4@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/python-dulwich
Branch : f44
Commit : c449203152d491be8a04bd20614871f393133c81
Author : Gwyn Ciesla <gwync@protonmail.com>
Date   : 2026-11-11T12:33:12-06:00
Stats  : +106/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-dulwich/c/c449203152d491be8a04bd20614871f393133c81?branch=f44

Log:
Patch for test failure

---
diff --git a/ce4136a3555c5c6e75ec4d94b3945605af4ff580.patch b/ce4136a3555c5c6e75ec4d94b3945605af4ff580.patch
new file mode 100644
index 0000000..cb32dda
--- /dev/null
+++ b/ce4136a3555c5c6e75ec4d94b3945605af4ff580.patch
@@ -0,0 +1,104 @@
+From ce4136a3555c5c6e75ec4d94b3945605af4ff580 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= <jelmer@jelmer.uk>
+Date: Thu, 5 Nov 2026 19:29:48 +0000
+Subject: [PATCH] pack: reject oversized object counts before __len__ (#2574)
+
+On 32-bit platforms Py_ssize_t is 32-bit signed, so a corrupt pack index
+with fanout[-1] above 2**31-1 made __len__ raise OverflowError before the
+size check could fail with AssertionError. Use _fan_out_table[-1] directly.
+---
+ NEWS            |  6 ++++++
+ dulwich/pack.py | 37 +++++++++++++++++++++++++------------
+ 2 files changed, 31 insertions(+), 12 deletions(-)
+
+diff --git a/NEWS b/NEWS
+index a556b7147d..1cd8e8d48a 100644
+--- a/NEWS
++++ b/NEWS
+@@ -1,3 +1,9 @@
++1.2.22	UNRELEASED
++
++ * Reject pack indexes whose fanout claims more than 2**31-1 objects on
++   32-bit platforms with AssertionError rather than OverflowError.
++   (Jelmer Vernooij, #2574)
++
+ 1.2.21	2026-11-04
+ 
+  * SECURITY: Refuse ``porcelain.submodule_update`` when the submodule path
+diff --git a/dulwich/pack.py b/dulwich/pack.py
+index 319245b3ce..45473c3ab5 100644
+--- a/dulwich/pack.py
++++ b/dulwich/pack.py
+@@ -1385,11 +1385,14 @@ def __init__(
+         self._fan_out_table = self._read_fan_out_table(0)
+         self.hash_size = self.object_format.oid_length
+         self._entry_size = 4 + self.hash_size
++        # Avoid len(self) here: on 32-bit platforms a __len__ return above
++        # 2**31-1 raises OverflowError before we can reject the index.
++        num_objects = self._fan_out_table[-1]
+         file_size = len(self._contents)
+-        minimum_size = 0x100 * 4 + len(self) * self._entry_size
++        minimum_size = 0x100 * 4 + num_objects * self._entry_size
+         if file_size < minimum_size:
+             raise AssertionError(
+-                f"pack index claims {len(self)} objects but file is only "
++                f"pack index claims {num_objects} objects but file is only "
+                 f"{file_size} bytes (needs at least {minimum_size})"
+             )
+ 
+@@ -1444,10 +1447,15 @@ def __init__(
+         self._fan_out_table = self._read_fan_out_table(8)
+         self.hash_size = self.object_format.oid_length
+         self._name_table_offset = 8 + 0x100 * 4
+-        self._crc32_table_offset = self._name_table_offset + self.hash_size * len(self)
+-        self._pack_offset_table_offset = self._crc32_table_offset + 4 * len(self)
+-        self._pack_offset_largetable_offset = self._pack_offset_table_offset + 4 * len(
+-            self
++        # Avoid len(self) here: on 32-bit platforms a __len__ return above
++        # 2**31-1 raises OverflowError before we can reject the index.
++        num_objects = self._fan_out_table[-1]
++        self._crc32_table_offset = (
++            self._name_table_offset + self.hash_size * num_objects
++        )
++        self._pack_offset_table_offset = self._crc32_table_offset + 4 * num_objects
++        self._pack_offset_largetable_offset = (
++            self._pack_offset_table_offset + 4 * num_objects
+         )
+         # Reject claims the file is obviously too small to back. A corrupt
+         # (or hostile) ``.idx`` with fanout[-1] = 0xFFFFFFFF would otherwise
+@@ -1460,7 +1468,7 @@ def __init__(
+         minimum_size = self._pack_offset_largetable_offset
+         if file_size < minimum_size:
+             raise AssertionError(
+-                f"pack index claims {len(self)} objects but file is only "
++                f"pack index claims {num_objects} objects but file is only "
+                 f"{file_size} bytes (needs at least {minimum_size})"
+             )
+ 
+@@ -1576,16 +1584,21 @@ def __init__(
+             16
+         )  # After header (4 + 4 + 4 + 4)
+         self._name_table_offset = 16 + 0x100 * 4
+-        self._crc32_table_offset = self._name_table_offset + self.hash_size * len(self)
+-        self._pack_offset_table_offset = self._crc32_table_offset + 4 * len(self)
+-        self._pack_offset_largetable_offset = self._pack_offset_table_offset + 4 * len(
+-            self
++        # Avoid len(self) here: on 32-bit platforms a __len__ return above
++        # 2**31-1 raises OverflowError before we can reject the index.
++        num_objects = self._fan_out_table[-1]
++        self._crc32_table_offset = (
++            self._name_table_offset + self.hash_size * num_objects
++        )
++        self._pack_offset_table_offset = self._crc32_table_offset + 4 * num_objects
++        self._pack_offset_largetable_offset = (
++            self._pack_offset_table_offset + 4 * num_objects
+         )
+         file_size = len(self._contents)
+         minimum_size = self._pack_offset_largetable_offset
+         if file_size < minimum_size:
+             raise AssertionError(
+-                f"pack index claims {len(self)} objects but file is only "
++                f"pack index claims {num_objects} objects but file is only "
+                 f"{file_size} bytes (needs at least {minimum_size})"
+             )
+ 

diff --git a/python-dulwich.spec b/python-dulwich.spec
index f950345..f528f0e 100644
--- a/python-dulwich.spec
+++ b/python-dulwich.spec
@@ -10,6 +10,8 @@ License:        GPL-2.0-or-later OR Apache-2.0
 URL:            https://www.dulwich.io/
 Source0:        %{pypi_source}
 
+Patch0:         ce4136a3555c5c6e75ec4d94b3945605af4ff580.patch
+
 BuildRequires:  python3-devel
 BuildRequires:  cargo-rpm-macros
 

                 reply	other threads:[~2026-11-11 18:35 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=179442211384.1.8466824432227101676.rpms-python-dulwich-c449203152d4@fedoraproject.org \
    --to=gwync@protonmail.com \
    --cc=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