Remove upstream patch

This commit is contained in:
Richard W.M. Jones 2025-08-23 17:30:58 +01:00
commit 812ce9e3f2
2 changed files with 0 additions and 219 deletions

View file

@ -1,216 +0,0 @@
From 05eea64423f1cd5c12ac4e7932389c64d58ac7fa Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 20 Aug 2025 16:44:59 +0100
Subject: [PATCH] indexed-gzip: Fixes for 32-bit support
On 32-bit i686 nbdkit-indexed-gzip-filter test crashes with:
realloc(): invalid pointer
Firstly include <config.h> consistently. I suspect an off_t 32/64-bit
mismatch causes this. In any case make sure _FILE_OFFSET_BITS is
consistent in all compilation units.
Also fix printf formatters for off_t, uint64_t and ptrdiff_t.
(https://stackoverflow.com/questions/586928/how-should-i-print-types-like-off-t-and-size-t)
This change seems to fix the crasher in practice, but I'm not certain
that I have identified the root cause.
---
filters/indexed-gzip/ig_handle.h | 1 -
filters/indexed-gzip/ig_zran.c | 52 ++++++++++++++++++++---------
filters/indexed-gzip/indexed_gzip.c | 5 +--
filters/indexed-gzip/zran.c | 2 ++
4 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/filters/indexed-gzip/ig_handle.h b/filters/indexed-gzip/ig_handle.h
index 168774f55b..3d478eaa57 100644
--- a/filters/indexed-gzip/ig_handle.h
+++ b/filters/indexed-gzip/ig_handle.h
@@ -54,7 +54,6 @@
#include "pread.h"
#include "minmax.h"
-
/* NBDkit filter handle containing the index */
struct handle {
struct deflate_index *index;
diff --git a/filters/indexed-gzip/ig_zran.c b/filters/indexed-gzip/ig_zran.c
index 88a94884b9..025186292c 100644
--- a/filters/indexed-gzip/ig_zran.c
+++ b/filters/indexed-gzip/ig_zran.c
@@ -2,7 +2,9 @@
* Copyright (C) 2005, 2012, 2018, 2023, 2024 Mark Adler
* Copyright (C) 2025 Shasheen Ediriweera
* For conditions of distribution and use, see copyright notice in zlib.h
- * Version 1.6 2 Aug 2024 Mark Adler */
+ * Version 1.6 2 Aug 2024 Mark Adler
+ */
+
#include <config.h>
#include <stdio.h>
@@ -33,8 +35,9 @@
int ig_deflate_index_build(nbdkit_next *next, void* handle, off_t span, int* nbdkit_err) {
struct handle *h = handle;
- nbdkit_debug("ig_deflate_index_build: starting with span=%ld, compressed_size=%lu",
- span, h->compressed_size);
+ nbdkit_debug("ig_deflate_index_build: "
+ "starting with span=%jd, compressed_size=%" PRIu64,
+ (intmax_t) span, h->compressed_size);
// Create and initialize the index list.
struct deflate_index *index = malloc(sizeof(struct deflate_index));
@@ -67,7 +70,11 @@ int ig_deflate_index_build(nbdkit_next *next, void* handle, off_t span, int* nbd
// Print how much of the file has been decompressed, for external applications to track progress of this long-lived operation
float new_progress = (float)totin / (float)h->compressed_size;
if (new_progress - decompression_progress > progress_print_threshold) {
- nbdkit_debug("ig_deflate_index_extract: total_in=%ld, compressed_size=%ld, progress=%f", index->strm.total_in, h->compressed_size, decompression_progress);
+ nbdkit_debug("ig_deflate_index_extract: "
+ "total_in=%ld, compressed_size=%" PRIu64 ", "
+ "progress=%f",
+ index->strm.total_in, h->compressed_size,
+ decompression_progress);
decompression_progress = new_progress;
}
@@ -144,8 +151,9 @@ int ig_deflate_index_build(nbdkit_next *next, void* handle, off_t span, int* nbd
// very start for the first access point, or there has been span or
// more uncompressed bytes since the last access point, so we want
// to add an access point here.
- nbdkit_debug("ig_deflate_index_build: adding access point at totout=%ld, have=%d",
- totout, index->have);
+ nbdkit_debug("ig_deflate_index_build: "
+ "adding access point at totout=%jd, have=%d",
+ (intmax_t) totout, index->have);
index = add_point(index, totin - index->strm.avail_in, totout, beg,
win);
if (index == NULL) {
@@ -184,8 +192,9 @@ int ig_deflate_index_build(nbdkit_next *next, void* handle, off_t span, int* nbd
index->mode = mode;
index->length = totout;
h->index = index;
- nbdkit_debug("ig_deflate_index_build: Successfully completed indexation, have=%d, length=%ld",
- index->have, totout);
+ nbdkit_debug("ig_deflate_index_build: "
+ "successfully completed indexation, have=%d, length=%jd",
+ index->have, (intmax_t) totout);
return index->have;
}
@@ -194,7 +203,9 @@ ptrdiff_t ig_deflate_index_extract(nbdkit_next *next, void *handle, off_t offset
struct handle *h = handle;
struct deflate_index* index = h->index;
- nbdkit_debug("ig_deflate_index_extract: starting with offset=%ld, len=%zu", offset, len);
+ nbdkit_debug("ig_deflate_index_extract: "
+ "starting with offset=%jd, len=%zu",
+ (intmax_t) offset, len);
// Do a quick sanity check on the index.
if (index == NULL || index->have < 1 || index->list[0].out != 0 ||
@@ -206,8 +217,10 @@ ptrdiff_t ig_deflate_index_extract(nbdkit_next *next, void *handle, off_t offset
// If nothing to extract, return zero bytes extracted.
if (len == 0 || offset < 0 || offset >= index->length) {
- nbdkit_debug("ig_deflate_index_extract: nothing to extract - len=%zu, offset=%ld, index->length=%ld",
- len, offset, index->length);
+ nbdkit_debug("ig_deflate_index_extract: "
+ "nothing to extract - len=%zu, offset=%jd, "
+ "index->length=%jd",
+ len, (intmax_t) offset, (intmax_t) index->length);
return 0;
}
@@ -223,8 +236,10 @@ ptrdiff_t ig_deflate_index_extract(nbdkit_next *next, void *handle, off_t offset
}
point += lo;
- nbdkit_debug("ig_deflate_index_extract: found access point %d - point->in=%ld, point->out=%ld, point->bits=%d",
- lo, point->in, point->out, point->bits);
+ nbdkit_debug("ig_deflate_index_extract: "
+ "found access point %d - point->in=%jd, point->out=%jd, "
+ "point->bits=%d",
+ lo, (intmax_t) point->in, (intmax_t) point->out, point->bits);
// Initialize the input file and prime the inflate engine to start there.
off_t start_byte = point->in - (point->bits ? 1 : 0);
@@ -232,7 +247,9 @@ ptrdiff_t ig_deflate_index_extract(nbdkit_next *next, void *handle, off_t offset
index->strm.avail_in = 0;
int ret = inflateReset2(&index->strm, RAW);
index->strm.total_in = start_byte;
- nbdkit_debug("ig_deflate_index_extract: inflateReset2 returned %d, start_byte=%ld", ret, start_byte);
+ nbdkit_debug("ig_deflate_index_extract: "
+ "inflateReset2 returned %d, start_byte=%jd",
+ ret, (intmax_t) start_byte);
if (ret != Z_OK)
return ret;
if (point->bits) {
@@ -248,7 +265,9 @@ ptrdiff_t ig_deflate_index_extract(nbdkit_next *next, void *handle, off_t offset
offset -= point->out; // number of bytes to skip to get to offset
size_t left = len; // number of bytes left to read after offset
- nbdkit_debug("ig_deflate_index_extract: adjusted offset=%ld, left=%zu", offset, left);
+ nbdkit_debug("ig_deflate_index_extract: "
+ "adjusted offset=%jd, left=%zu",
+ (intmax_t) offset, left);
do {
if (offset) {
@@ -362,7 +381,8 @@ ptrdiff_t ig_deflate_index_extract(nbdkit_next *next, void *handle, off_t offset
// Return the number of uncompressed bytes read into buf, or the error.
ptrdiff_t result = ret == Z_OK || ret == Z_STREAM_END ? len - left : ret;
- nbdkit_debug("ig_deflate_index_extract: completed with result=%ld, ret=%d, len=%zu, left=%zu",
+ nbdkit_debug("ig_deflate_index_extract: "
+ "completed with result=%td, ret=%d, len=%zu, left=%zu",
result, ret, len, left);
return result;
}
diff --git a/filters/indexed-gzip/indexed_gzip.c b/filters/indexed-gzip/indexed_gzip.c
index 87c08f8e57..f47e41ecdb 100644
--- a/filters/indexed-gzip/indexed_gzip.c
+++ b/filters/indexed-gzip/indexed_gzip.c
@@ -31,7 +31,6 @@
*/
#include <config.h>
-#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -41,6 +40,7 @@
#include <fcntl.h>
#include <pthread.h>
#include <sys/stat.h>
+#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <limits.h>
@@ -309,7 +309,8 @@ indexed_gzip_pread(nbdkit_next *next, void *handle,
default:
//
*err = EIO;
- nbdkit_error(FILTER_NAME ": error %ld while extracting value\n", len);
+ nbdkit_error(FILTER_NAME ": error %jd while extracting value\n",
+ (intmax_t) len);
}
return -1;
}
diff --git a/filters/indexed-gzip/zran.c b/filters/indexed-gzip/zran.c
index 5c924dfebe..6a6e087e28 100644
--- a/filters/indexed-gzip/zran.c
+++ b/filters/indexed-gzip/zran.c
@@ -60,6 +60,8 @@
// use of pointers in the state. The approach here allows for storage of the
// index in a file.
+#include <config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
--
2.50.1

View file

@ -86,9 +86,6 @@ Source6: %{modulename}.te
Source7: %{modulename}.if
Source8: %{modulename}.fc
# Upstream fix for 32-bit indexed-gzip filter.
Patch: 0001-indexed-gzip-Fixes-for-32-bit-support.patch
# For applying the patches:
BuildRequires: git