Package: hfsutils
Version: 3.2.6-16
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu oracular ubuntu-patch

Dear Maintainer,

This patch does the following:

  * d/rules: switch to use the debhelper autoreconf template.
    - d/rules: disable parallel testing.
    - d/hfsutils-tcltk.links: remove, this is auto-handled by debhelper now.
  * d/p/0006-Fix-memory-corruption.patch: add a patch to fix memory corruption
    issues (LP: #493273).


Thanks for considering the patch.


-- System Information:
Debian Release: trixie/sid
  APT prefers noble-updates
  APT policy: (500, 'noble-updates'), (500, 'noble-security'), (500, 'noble'), 
(100, 'noble-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.8.0-35-generic (SMP w/10 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_CA:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru hfsutils-3.2.6/debian/compat hfsutils-3.2.6/debian/compat
--- hfsutils-3.2.6/debian/compat        2021-01-23 07:13:30.000000000 -0700
+++ hfsutils-3.2.6/debian/compat        1969-12-31 17:00:00.000000000 -0700
@@ -1 +0,0 @@
-10
diff -Nru hfsutils-3.2.6/debian/control hfsutils-3.2.6/debian/control
--- hfsutils-3.2.6/debian/control       2021-10-17 09:09:15.000000000 -0600
+++ hfsutils-3.2.6/debian/control       2024-06-11 15:24:07.000000000 -0600
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de>
 Standards-Version: 4.1.3
-Build-Depends: debhelper (>= 10), tcl-dev, tk-dev
+Build-Depends: debhelper-compat (= 13), tcl-dev, tk-dev
 Homepage: http://www.mars.org/home/rob/proj/hfs/
 Vcs-Browser: https://salsa.debian.org/debian/hfsutils
 Vcs-Git: https://salsa.debian.org/debian/hfsutils.git
diff -Nru hfsutils-3.2.6/debian/hfsutils-tcltk.links 
hfsutils-3.2.6/debian/hfsutils-tcltk.links
--- hfsutils-3.2.6/debian/hfsutils-tcltk.links  2021-01-23 07:13:30.000000000 
-0700
+++ hfsutils-3.2.6/debian/hfsutils-tcltk.links  1969-12-31 17:00:00.000000000 
-0700
@@ -1 +0,0 @@
-usr/share/doc/hfsutils usr/share/doc/hfsutils-tcltk
diff -Nru hfsutils-3.2.6/debian/patches/0006-Fix-memory-corruption.patch 
hfsutils-3.2.6/debian/patches/0006-Fix-memory-corruption.patch
--- hfsutils-3.2.6/debian/patches/0006-Fix-memory-corruption.patch      
1969-12-31 17:00:00.000000000 -0700
+++ hfsutils-3.2.6/debian/patches/0006-Fix-memory-corruption.patch      
2024-06-11 15:24:07.000000000 -0600
@@ -0,0 +1,57 @@
+Description: Fix memory corruption in hfssh
+ This was caused by mismatched alloc/free functions.
+ Memory allocated by Tcl must be freed by TclFree and memory transferred to
+ Tcl must be allocated using TclAlloc.
+Author: Zixing Liu <zixing....@canonical.com>
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=421457
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/hfsutils/+bug/493273
+Forwarded: no
+Last-Update: 2024-06-11
+---
+Index: hfsutils/tclhfs.c
+===================================================================
+--- hfsutils.orig/tclhfs.c
++++ hfsutils/tclhfs.c
+@@ -378,7 +378,7 @@ int file_cmd(ClientData clientData, Tcl_
+             return TCL_ERROR;
+           }
+ 
+-        mem = ALLOC(char, bytes + 1);
++        mem = Tcl_Alloc(bytes + 1);
+         if (mem == 0)
+           {
+             interp->result = "out of memory";
+@@ -1038,7 +1038,7 @@ int vol_cmd(ClientData clientData, Tcl_I
+           return TCL_ERROR;
+ 
+         fargv = hfs_glob(vol, listc, listv, &fargc);
+-        free(listv);
++        Tcl_Free(listv);
+ 
+         if (fargv == 0)
+           {
+@@ -1313,7 +1313,7 @@ int cmd_hfs(ClientData clientData, Tcl_I
+         badblocks = ALLOCX(unsigned long, listc);
+         if (listc && badblocks == 0)
+           {
+-            free(listv);
++            Tcl_Free(listv);
+ 
+             interp->result = "out of memory";
+             return TCL_ERROR;
+@@ -1324,13 +1324,13 @@ int cmd_hfs(ClientData clientData, Tcl_I
+             if (Tcl_ExprLong(interp, listv[i],
+                              (long *) &badblocks[i]) != TCL_OK)
+               {
+-                free(listv);
++                Tcl_Free(listv);
+                 FREE(badblocks);
+                 return TCL_ERROR;
+               }
+           }
+ 
+-        free(listv);
++        Tcl_Free(listv);
+ 
+         if (do_format(argv[2], partno, 0, argv[4], listc, badblocks) == -1)
+           {
diff -Nru hfsutils-3.2.6/debian/patches/series 
hfsutils-3.2.6/debian/patches/series
--- hfsutils-3.2.6/debian/patches/series        2024-04-14 05:45:36.000000000 
-0600
+++ hfsutils-3.2.6/debian/patches/series        2024-06-11 15:24:07.000000000 
-0600
@@ -3,3 +3,4 @@
 0003-Add-support-for-files-larger-than-2GB.patch
 0004-Add-DUSE_INTERP_RESULT-to-DEFINES-in-Makefile.in.patch
 0005-Fix-missing-inclusion-of-string.h-in-hpwd.c.patch
+0006-Fix-memory-corruption.patch
diff -Nru hfsutils-3.2.6/debian/rules hfsutils-3.2.6/debian/rules
--- hfsutils-3.2.6/debian/rules 2021-01-23 07:13:30.000000000 -0700
+++ hfsutils-3.2.6/debian/rules 2024-06-11 15:24:07.000000000 -0600
@@ -5,82 +5,19 @@
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
-MAKE += -o configure.in
+%:
+       dh $@
 
-CFLAGS = -Wall $(shell dpkg-buildflags --get CPPFLAGS; dpkg-buildflags --get 
CFLAGS)
-LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
-
-build-arch: build
-build-indep: build
-build: build-stamp
-build-stamp:
+override_dh_auto_configure:
        dh_testdir
-
-       # Add here commands to compile the package.
-       CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --prefix=/usr \
-                   --mandir=\$${prefix}/share/man \
+       dh_auto_configure -- \
                    --with-tcl=/usr/lib \
                    --with-tk=/usr/lib
-       $(MAKE)
-
-       touch build-stamp
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp
-
-       # Add here commands to clean up after the build process.
-       [ ! -f Makefile ] || $(MAKE) distclean
 
-       dh_clean
+override_dh_auto_test:
+       # Tests can't be run in parallel
+       dh_auto_test -- -j1
 
-install: build
-       dh_testdir
-       dh_testroot
-       dh_prep
-       dh_installdirs
-
-       # Add here commands to install the package into debian/<packagename>
+override_dh_auto_install:
        $(MAKE) prefix=$(CURDIR)/debian/hfsutils/usr install_cli
        $(MAKE) prefix=$(CURDIR)/debian/hfsutils-tcltk/usr install_tcl 
install_tk
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-       dh_testdir
-       dh_testroot
-       dh_link
-       dh_installchangelogs CHANGES
-       dh_installdocs
-       dh_installexamples
-#      dh_install
-#      dh_installmenu
-#      dh_installdebconf       
-#      dh_installlogrotate
-#      dh_installemacsen
-#      dh_installcatalogs
-#      dh_installpam
-#      dh_installmime
-#      dh_installinit
-#      dh_installcron
-#      dh_installinfo
-#      dh_undocumented
-       dh_installman
-       dh_strip
-       dh_compress
-       dh_fixperms
-#      dh_perl
-#      dh_python
-#      dh_makeshlibs
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-       dh_md5sums
-       dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean clean1 binary-indep binary-arch binary install

Reply via email to