Module Name: src Committed By: rillig Date: Tue Jun 25 05:18:39 UTC 2024
Modified Files: src/usr.bin/make: job.c test-variants.mk Log Message: make: fix invalid-free for custom shell definitions Don't try to free a pointer that is taken from the middle of a string, in this case a shell specification. To generate a diff of this commit: cvs rdiff -u -r1.476 -r1.477 src/usr.bin/make/job.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/test-variants.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.476 src/usr.bin/make/job.c:1.477 --- src/usr.bin/make/job.c:1.476 Sat Jun 15 20:02:45 2024 +++ src/usr.bin/make/job.c Tue Jun 25 05:18:38 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.476 2024/06/15 20:02:45 rillig Exp $ */ +/* $NetBSD: job.c,v 1.477 2024/06/25 05:18:38 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.476 2024/06/15 20:02:45 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.477 2024/06/25 05:18:38 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -2137,7 +2137,7 @@ InitShellNameAndPath(void) #ifdef DEFSHELL_CUSTOM if (shellName[0] == '/') { - shellPath = shellName; + shellPath = bmake_strdup(shellName); shellName = str_basename(shellPath); return; } @@ -2480,7 +2480,7 @@ Job_ParseShell(char *line) } } else { free(UNCONST(shellPath)); - shellPath = path; + shellPath = bmake_strdup(path); shellName = newShell.name != NULL ? newShell.name : str_basename(path); if (!fullSpec) { Index: src/usr.bin/make/test-variants.mk diff -u src/usr.bin/make/test-variants.mk:1.8 src/usr.bin/make/test-variants.mk:1.9 --- src/usr.bin/make/test-variants.mk:1.8 Sat May 25 00:00:25 2024 +++ src/usr.bin/make/test-variants.mk Tue Jun 25 05:18:38 2024 @@ -1,4 +1,4 @@ -# $NetBSD: test-variants.mk,v 1.8 2024/05/25 00:00:25 rillig Exp $ +# $NetBSD: test-variants.mk,v 1.9 2024/06/25 05:18:38 rillig Exp $ # # Build several variants of make and run the tests on them. # @@ -200,8 +200,15 @@ CFLAGS.gcc-warn+= -Wno-error=duplicated- .for shell in /usr/pkg/bin/bash /usr/pkg/bin/dash . if exists(${shell}) -TESTS+= ${shell:T} +TESTS+= ${shell:T} CPPFLAGS.${shell:T}= -DDEFSHELL_CUSTOM="\"${shell}\"" + +. for name in ${shell:T}-sanitize +TESTS+= ${name} +ENV.${name}= MKSANITIZER=yes LIMIT_RESOURCES=: +CPPFLAGS.${name}= -DDEFSHELL_CUSTOM="\"${shell}\"" -DCLEANUP +CFLAGS.${name}= -ggdb -O0 +. endfor . endif .endfor