File texinfo-zlib.patch of Package texinfo
From 91e8a3ccdccebe95aa9ed8af39609f5c28420f6c Mon Sep 17 00:00:00 2001
From: Jan Fooken <jan.fooken@suse.com>
Date: Fri, 5 Sep 2025 17:08:36 +0200
Subject: [PATCH] Fix and update internal compression patch
This commit adds compression logic to texinfo, to handle the
decompression of info files via zio instead of shelling out to external
programs. This was a previously existing patch, which was updated to
7.2. The previous patch contained error handling of the wrong file and
potentially leaked the memory of the variable command. This addresses
these shortcomings
---
install-info/Makefile.in | 2 +-
install-info/install-info.c | 43 ++++++++++++++++++++++++++-----------
2 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/install-info/Makefile.in b/install-info/Makefile.in
index cb419f9..ab81869 100644
--- a/install-info/Makefile.in
+++ b/install-info/Makefile.in
@@ -276,7 +276,7 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_ginstall_info_OBJECTS = install-info.$(OBJEXT)
ginstall_info_OBJECTS = $(am_ginstall_info_OBJECTS)
-ginstall_info_LDADD = $(LDADD)
+ginstall_info_LDADD = $(LDADD) -lzio
am__DEPENDENCIES_1 =
ginstall_info_DEPENDENCIES = $(top_builddir)/gnulib/lib/libgnu.a \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
diff --git a/install-info/install-info.c b/install-info/install-info.c
index 3ea11fb..ee077d9 100644
--- a/install-info/install-info.c
+++ b/install-info/install-info.c
@@ -19,6 +19,7 @@
#include <getopt.h>
#include <regex.h>
#include <argz.h>
+#include <zio.h>
#define TAB_WIDTH 8
@@ -827,23 +828,41 @@ determine_file_type:
if (*compression_program)
{
- /* Redirect stdin to the file and fork the decompression process
- reading from stdin. This allows shell metacharacters in filenames. */
+ FILE *fz = f;
if (fclose (f) < 0)
return 0;
- if (!freopen (*opened_filename, FOPEN_RBIN, stdin))
- return 0;
- char *command = concat (*compression_program, " -d", "");
- f = popen (command, "r");
- fclose (stdin);
- if (!f)
+
+ if (**compression_program == 'g' || **compression_program == 'z')
+ fz = fzopen (*opened_filename, "rg");
+ if (**compression_program == 'b')
+ fz = fzopen (*opened_filename, "rb");
+ if (**compression_program == 'Z')
+ fz = fzopen (*opened_filename, "rZ");
+ if (**compression_program == 'l')
+ fz = fzopen (*opened_filename, "rl");
+ if (**compression_program == 'x')
+ fz = fzopen (*opened_filename, "rx");
+ if (!fz)
{
- /* Used for error message in calling code. */
- *opened_filename = command;
- return 0;
+ /* Redirect stdin to the file and fork the decompression process
+ reading from stdin. This allows shell metacharacters in filenames. */
+ FILE *f2 = freopen (*opened_filename, FOPEN_RBIN, stdin);
+ if (!f2)
+ return 0;
+ char *command = concat (*compression_program, " -d", "");
+ f = popen (command, "r");
+ fclose (f2);
+ if (!f)
+ {
+ /* Used for error message in calling code. */
+ *opened_filename = command;
+ return 0;
+ }
+ free (command);
}
- free (command);
+ else
+ f = fz;
}
else
{
--
2.51.0