[bug #67777] make mangles .SHELLFLAGS to death (buffer overflow, and more...)
Dmitry Goncharov <[email protected]> Fri, 5 Dec 2025 22:59:13 -0500 (EST)
| Newsgroups | gmane.comp.gnu.make.bugs |
|---|---|
| Message-ID | <[email protected]> |
Follow-up Comment #1, bug #67777 (group make):
This is a duplicate of https://savannah.gnu.org/bugs/?65588.
Even though preallocating memory fixes the segmentation fault the behavior is
still incorrect
$ ls
makefile
$ cat makefile
.ONESHELL:
.SHELLFLAGS:=-c 'echo hello
all:;:
$ make
a = "/bin/sh"
a = "/bin/sh"
a = ""
a = "c 'echo hello"
a = ":"
:
/bin/sh: 2: Syntax error: "(" unexpected
make_bad_with_extra_memory_allocated: *** [makefile:3: all] Error 2
$
$
We can see here that argv is incorrect.
1. - is stripped from -c.
2. the first arg to the second /bin/sh is empty.
The result is a shell that exits with a wrong message about unexpected "(".
If we apply the patch from https://savannah.gnu.org/bugs/?65588.
$ ls
makefile
$ cat makefile
.ONESHELL:
.SHELLFLAGS:=-c 'echo hello
all:;:
$ make
"/bin/sh"
"-c"
"/bin/sh -c 'echo hello :"
:
/bin/sh: 1: Syntax error: Unterminated quoted string
make: *** [makefile:3: all] Error 2
$
We can see here that argv is correct and shell exits with the expected error
message about unterminated quoted string.
Unrelated to the buffer overflow, this argv passes /bin/sh through /bin/sh.
This may be a (benign?) bug of its own or it may be intentional.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?67777>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaTOqEQAKCRCqLAuaBUf3 ThnpAP9yzu8qYGD0dO6n4EbGJ1MfefAIu6iLIjf58ELxMtyQLgD/aX8aIOHh4cro 5hypqDbpRMyZ1LIGnzV2t/j00B4idAM= =oy5x -----END PGP SIGNATURE-----