public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-dulwich] f44: Patch for test failure
@ 2026-11-11 18:35 Gwyn Ciesla
0 siblings, 0 replies; only message in thread
From: Gwyn Ciesla @ 2026-11-11 18:35 UTC (permalink / raw)
To: git-commits
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-11 18:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 18:35 [rpms/python-dulwich] f44: Patch for test failure Gwyn Ciesla
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox