From 46ce787b63d467d9b8e5ef8821e2ddefea4b980a Mon Sep 17 00:00:00 2001 From: Duncaen Date: Sat, 15 Apr 2023 17:18:30 +0200 Subject: [PATCH] chroot-distcc: update to 3.4. --- ...cc_rewrite_fqn-avoid-heap-corruption.patch | 65 +++++++++++++++++++ srcpkgs/chroot-distcc/patches/gcc-10.patch | 15 +++++ srcpkgs/chroot-distcc/template | 19 ++---- 3 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 srcpkgs/chroot-distcc/patches/dcc_gcc_rewrite_fqn-avoid-heap-corruption.patch create mode 100644 srcpkgs/chroot-distcc/patches/gcc-10.patch diff --git a/srcpkgs/chroot-distcc/patches/dcc_gcc_rewrite_fqn-avoid-heap-corruption.patch b/srcpkgs/chroot-distcc/patches/dcc_gcc_rewrite_fqn-avoid-heap-corruption.patch new file mode 100644 index 00000000000..5d0a86d2f1a --- /dev/null +++ b/srcpkgs/chroot-distcc/patches/dcc_gcc_rewrite_fqn-avoid-heap-corruption.patch @@ -0,0 +1,65 @@ +commit 879b71d6e95673e58d33f6c3c341a893ee307161 +Author: Alexey Sheplyakov +Date: Sat Jul 10 22:18:14 2021 +0400 + + dcc_gcc_rewrite_fqn: avoid heap corruption + + On ALT Linux I've run into the following bug: + + distcc gcc -Wall -std=gnu89 -I. -O2 -o hello.o -c hello.c + free(): invalid next size (fast) + Aborted (core dumped) + + Apparently dcc_gcc_rewrite writes beyond the allocated memory: + + valgrind --leak-check=full -v ./distcc gcc -Wall -std=gnu89 -I. -O2 -o hello.o -c hello.c + + ==11382== ERROR SUMMARY: 53 errors from 5 contexts (suppressed: 0 from 0) + ==11382== + ==11382== 1 errors in context 1 of 5: + ==11382== Invalid write of size 1 + ==11382== at 0x4C349D8: strcat (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + ==11382== by 0x10D165: dcc_gcc_rewrite_fqn (compile.c:611) + ==11382== by 0x10D4B4: dcc_build_somewhere (compile.c:725) + ==11382== by 0x10DC01: dcc_build_somewhere_timed (compile.c:1014) + ==11382== by 0x10E380: main (distcc.c:352) + ==11382== Address 0x544e828 is 1 bytes after a block of size 23 alloc'd + ==11382== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + ==11382== by 0x10D087: dcc_gcc_rewrite_fqn (compile.c:588) + ==11382== by 0x10D4B4: dcc_build_somewhere (compile.c:725) + ==11382== by 0x10DC01: dcc_build_somewhere_timed (compile.c:1014) + ==11382== by 0x10E380: main (distcc.c:352) + ==11382== + ==11382== + ==11382== 1 errors in context 2 of 5: + ==11382== Invalid write of size 1 + ==11382== at 0x4C349C8: strcat (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + ==11382== by 0x10D165: dcc_gcc_rewrite_fqn (compile.c:611) + ==11382== by 0x10D4B4: dcc_build_somewhere (compile.c:725) + ==11382== by 0x10DC01: dcc_build_somewhere_timed (compile.c:1014) + ==11382== by 0x10E380: main (distcc.c:352) + ==11382== Address 0x544e827 is 0 bytes after a block of size 23 alloc'd + ==11382== at 0x4C31B0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) + ==11382== by 0x10D087: dcc_gcc_rewrite_fqn (compile.c:588) + ==11382== by 0x10D4B4: dcc_build_somewhere (compile.c:725) + ==11382== by 0x10DC01: dcc_build_somewhere_timed (compile.c:1014) + ==11382== by 0x10E380: main (distcc.c:352) + + and ALT Linux' hardened glibc does not quite like that. + Correctly compute the `newcmd_len` to avoid the problem. + + ALTBUG: #40425 + +diff --git a/src/compile.c b/src/compile.c +index 34964566fdd6..26d7d1821501 100644 +--- a/src/compile.c ++++ b/src/compile.c +@@ -584,7 +584,7 @@ static int dcc_gcc_rewrite_fqn(char **argv) + return -ENOENT; + + +- newcmd_len = strlen(target_with_vendor) + 1 + strlen(argv[0] + 1); ++ newcmd_len = strlen(target_with_vendor) + 1 + strlen(argv[0]) + 1; + newcmd = malloc(newcmd_len); + if (!newcmd) + return -ENOMEM; diff --git a/srcpkgs/chroot-distcc/patches/gcc-10.patch b/srcpkgs/chroot-distcc/patches/gcc-10.patch new file mode 100644 index 00000000000..599de51e0d9 --- /dev/null +++ b/srcpkgs/chroot-distcc/patches/gcc-10.patch @@ -0,0 +1,15 @@ +Upstream: Should be +Reason: Fixes compilation under gcc-10 which has -fno-common + +diff --git a/src/stats.c b/src/stats.c +index 35dbf7d..76bfbee 100644 +--- a/src/stats.c ++++ b/src/stats.c +@@ -82,7 +82,7 @@ struct statsdata { + char compiler[MAX_FILENAME_LEN]; + }; + +-const char *stats_text[20] = { "TCP_ACCEPT", "REJ_BAD_REQ", "REJ_OVERLOAD", ++extern const char *stats_text[20] = { "TCP_ACCEPT", "REJ_BAD_REQ", "REJ_OVERLOAD", + "COMPILE_OK", "COMPILE_ERROR", "COMPILE_TIMEOUT", "CLI_DISCONN", + "OTHER" }; diff --git a/srcpkgs/chroot-distcc/template b/srcpkgs/chroot-distcc/template index 8391ec04cf7..00810870a7b 100644 --- a/srcpkgs/chroot-distcc/template +++ b/srcpkgs/chroot-distcc/template @@ -1,6 +1,6 @@ # Template file for 'chroot-distcc' pkgname=chroot-distcc -version=3.3.3 +version=3.4 revision=1 bootstrap=yes build_style=gnu-configure @@ -12,24 +12,15 @@ maintainer="Enno Boland " license="GPL-2.0-or-later" homepage="https://distcc.github.io" distfiles="https://github.com/distcc/distcc/releases/download/v${version}/distcc-${version}.tar.gz" -checksum=bead25471d5a53ecfdf8f065a6fe48901c14d5008956c318c700e56bc87bf0bc +checksum=2b99edda9dad9dbf283933a02eace6de7423fe5650daa4a728c950e5cd37bd7d repository=bootstrap conflicts="distcc>=0" -CFLAGS="-fcommon" if [ "$CHROOT_READY" ]; then makedepends="binutils-devel" fi -pre_configure() { - # Copy files generated by package distcc running autogen.sh - # Manual update is required for every new version - cp -p "${FILESDIR}"/configure ${wrksrc} - cp -p "${FILESDIR}"/Makefile.in ${wrksrc} - cp -p "${FILESDIR}"/config.h.in ${wrksrc}/src -} - post_install() { local f x # Remove useless files. @@ -39,13 +30,13 @@ post_install() { # gcc wrappers vmkdir usr/lib/distcc/bin - for f in gcc cc c++ g++; do + for f in gcc cc c++ g++ cpp; do ln -sfr ${DESTDIR}/usr/bin/distcc ${DESTDIR}/usr/lib/distcc/bin/${f} done # cross-gcc wrappers for x in arm-linux-gnueabi arm-linux-gnueabihf armv7l-linux-gnueabihf \ - arm-linux-musleabihf armv7l-linux-musleabihf; do - for f in gcc cc c++ g++; do + arm-linux-musleabihf armv7l-linux-musleabihf aarch64-linux-gnu aarch64-linux-musl; do + for f in gcc cc c++ g++ cpp; do ln -sfr ${DESTDIR}/usr/bin/distcc ${DESTDIR}/usr/lib/distcc/bin/${x}-${f} done done