heirloom-no_alloca.patch (2672B)
- From c69bc8007b292b9040d398c5507c415427c7dff1 Mon Sep 17 00:00:00 2001
- From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
- Date: Sun, 2 Feb 2025 15:07:33 +0100
- Subject: [PATCH 1/2] tar/tar.c: remove usage of alloca()
- ---
- tar/tar.c | 11 +++++++----
- 1 file changed, 7 insertions(+), 4 deletions(-)
- diff --git a/tar/tar.c b/tar/tar.c
- index 7985d93..2ad9fb2 100644
- --- a/tar/tar.c
- +++ b/tar/tar.c
- @@ -81,7 +81,6 @@ static const char sccsid[] USED = "@(#)tar.sl 1.177 (gritter) 4/14/07";
- #include <inttypes.h>
- #include <iblok.h>
- #include <locale.h>
- -#include <alloca.h>
- #include <sys/ioctl.h>
- @@ -2027,12 +2026,12 @@ bsrch(const char *s, int n, off_t l, off_t h)
- char *b;
- off_t m, m1;
- - b = alloca(N);
- + b = malloc(N);
- njab = 0;
- loop:
- if(l >= h)
- - return(-1L);
- + goto fail;
- m = l + (h-l)/2 - N/2;
- if(m < l)
- m = l;
- @@ -2045,7 +2044,7 @@ bsrch(const char *s, int n, off_t l, off_t h)
- m++;
- }
- if(m >= h)
- - return(-1L);
- + goto fail;
- m1 = m;
- j = i;
- for(i++; i<N; i++) {
- @@ -2063,6 +2062,10 @@ bsrch(const char *s, int n, off_t l, off_t h)
- goto loop;
- }
- return(m);
- +
- +fail:
- + free(b);
- + return(-1L);
- }
- static int
- --
- 2.45.3
- From 8b217e567deae47e92796580dc1684adc6a86efa Mon Sep 17 00:00:00 2001
- From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
- Date: Sun, 2 Feb 2025 15:09:07 +0100
- Subject: [PATCH 2/2] libcommon: get rid of custom getopt (due to alloca)
- musl getopt being good anyway
- ---
- libcommon/Makefile.mk | 6 +-----
- 1 file changed, 1 insertion(+), 5 deletions(-)
- diff --git a/libcommon/Makefile.mk b/libcommon/Makefile.mk
- index 7ef8de1..c9764e6 100644
- --- a/libcommon/Makefile.mk
- +++ b/libcommon/Makefile.mk
- @@ -4,7 +4,7 @@ OBJ = asciitype.o ib_alloc.o ib_close.o ib_free.o ib_getlin.o ib_getw.o \
- ib_open.o ib_popen.o ib_read.o ib_seek.o oblok.o sfile.o strtol.o \
- getdir.o gmatch.o utmpx.o memalign.o pathconf.o \
- sigset.o signal.o sigrelse.o sighold.o sigignore.o sigpause.o \
- - getopt.o pfmt.o vpfmt.o setlabel.o setuxlabel.o pfmt_label.o sysv3.o
- + pfmt.o vpfmt.o setlabel.o setuxlabel.o pfmt_label.o sysv3.o
- libcommon.a: headers $(OBJ)
- $(AR) -rv $@ $(OBJ)
- $(RANLIB) $@
- @@ -101,9 +101,6 @@ pathconf.o: pathconf.c
- strtol.o: strtol.c
- $(CC) $(CFLAGSS) $(CPPFLAGS) $(LARGEF) $(IWCHAR) -I. -c strtol.c
- -getopt.o: getopt.c
- - $(CC) $(CFLAGSS) $(CPPFLAGS) $(LARGEF) $(IWCHAR) -I. -c getopt.c
- -
- sysv3.o: sysv3.c
- $(CC) $(CFLAGSS) $(CPPFLAGS) $(LARGEF) $(IWCHAR) -I. -c sysv3.c
- @@ -143,7 +140,6 @@ pfmt.o: pfmt.h
- vpfmt.o: pfmt.h
- setlabel.o: pfmt.h
- setuxlabel.o: pfmt.h msgselect.h
- -getopt.o: msgselect.h
- sighold.o: sigset.h
- sigignore.o: sigset.h
- sigpause.o: sigset.h
- --
- 2.45.3