Skip to content

Commit

Permalink
mamake: fix UB in legacy mode 'prev' command (re: 07a4fc6)
Browse files Browse the repository at this point in the history
Building old commits that use legacy mode Mamfiles was failing due
to a bug in the 'prev' command.

In mamake.c on line 2392, the pointer returned by the legacy dummt
'rule' call must be assigned to q. It wasn't, so the update_allprev
call on line 2422 had undefined behaviour as it passes q, which is
dereferenced on line 2010.
  • Loading branch information
McDutchie committed Nov 24, 2024
1 parent da0a769 commit f9c88f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cmd/INIT/mamake.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* coded for portability
*/

#define RELEASE_DATE "2024-11-01"
#define RELEASE_DATE "2024-11-23"
static char id[] = "\n@(#)$Id: mamake (ksh 93u+m) " RELEASE_DATE " $\0\n";

#if _PACKAGE_ast
Expand Down Expand Up @@ -2389,7 +2389,7 @@ static void make(Rule_t *r, Makestate_t *parentstate)
const int makp = (u[0] == 'm');
q = getval(state.rules, t);
if (!q && !makp && !state.strict)
rule(t); /* for backward compat */
q = rule(t); /* for backward compat */
else if (!q && (makp || state.strict < 4))
{
/* declare a simple source file prerequisite */
Expand Down

0 comments on commit f9c88f9

Please sign in to comment.