mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-05-05 20:36:40 +02:00
58 lines
2.8 KiB
Diff
58 lines
2.8 KiB
Diff
Patch-Source: https://github.com/borgbackup/borg/pull/9522
|
|
|
|
From 7fd6df2514c084fdf28dea557e49018610ffb10a Mon Sep 17 00:00:00 2001
|
|
From: Thomas Waldmann <tw@waldmann-edv.de>
|
|
Date: Thu, 19 Mar 2026 15:14:57 +0100
|
|
Subject: [PATCH] hashindex: fix new checks for big endian archs, fixes #9521
|
|
|
|
---
|
|
src/borg/_hashindex.c | 17 ++++++++++-------
|
|
1 file changed, 10 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/src/borg/_hashindex.c b/src/borg/_hashindex.c
|
|
index 9e1aab0842..11052aec29 100644
|
|
--- a/src/borg/_hashindex.c
|
|
+++ b/src/borg/_hashindex.c
|
|
@@ -371,6 +371,9 @@ hashindex_read(PyObject *file_py, int permit_compact, int expected_key_size, int
|
|
}
|
|
|
|
// check if key / value sizes match the expected sizes.
|
|
+ int header_num_buckets = _le32toh(header->num_buckets);
|
|
+ int header_num_entries = _le32toh(header->num_entries);
|
|
+
|
|
if (expected_key_size != -1 && header->key_size != expected_key_size) {
|
|
PyErr_Format(PyExc_ValueError, "Expected key size %d, got %d.",
|
|
expected_key_size, header->key_size);
|
|
@@ -391,24 +394,24 @@ hashindex_read(PyObject *file_py, int permit_compact, int expected_key_size, int
|
|
goto fail_decref_header;
|
|
}
|
|
// sanity check for num_buckets and num_entries.
|
|
- if (header->num_buckets < 1) {
|
|
- PyErr_Format(PyExc_ValueError, "Expected num_buckets >= 1, got %d.", header->num_buckets);
|
|
+ if (header_num_buckets < 1) {
|
|
+ PyErr_Format(PyExc_ValueError, "Expected num_buckets >= 1, got %d.", header_num_buckets);
|
|
goto fail_decref_header;
|
|
}
|
|
- if ((header->num_entries < 0) || (header->num_entries > header->num_buckets)) {
|
|
- PyErr_Format(PyExc_ValueError, "Expected 0 <= num_entries <= num_buckets, got %d.", header->num_entries);
|
|
+ if ((header_num_entries < 0) || (header_num_entries > header_num_buckets)) {
|
|
+ PyErr_Format(PyExc_ValueError, "Expected 0 <= num_entries <= num_buckets, got %d.", header_num_entries);
|
|
goto fail_decref_header;
|
|
}
|
|
|
|
- buckets_length = (Py_ssize_t)_le32toh(header->num_buckets) * (header->key_size + header->value_size);
|
|
+ buckets_length = (Py_ssize_t)header_num_buckets * (header->key_size + header->value_size);
|
|
if((Py_ssize_t)length != (Py_ssize_t)sizeof(HashHeader) + buckets_length) {
|
|
PyErr_Format(PyExc_ValueError, "Incorrect file length (expected %zd, got %zd)",
|
|
sizeof(HashHeader) + buckets_length, length);
|
|
goto fail_release_header_buffer;
|
|
}
|
|
|
|
- index->num_entries = _le32toh(header->num_entries);
|
|
- index->num_buckets = _le32toh(header->num_buckets);
|
|
+ index->num_entries = header_num_entries;
|
|
+ index->num_buckets = header_num_buckets;
|
|
index->key_size = header->key_size;
|
|
index->value_size = header->value_size;
|
|
index->bucket_size = index->key_size + index->value_size;
|