PR bin/55979

This fixes the MSAN detected reference to an unitialised variable
(an unitialised field in a struct) which happens when a command is
not found after a PATH search.

Aside from skipping some known to be going to fail exec*() calls
in some cases, the setting of the relevant field is irrelevant,
so this problem makes no practical difference to the shell, or any
shell script.

XXX (maybe) pullup -9
This commit is contained in:
kre 2021-02-16 15:30:12 +00:00
parent a9214ed12d
commit f49e0d69dd
1 changed files with 6 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $ */
/* $NetBSD: exec.c,v 1.55 2021/02/16 15:30:12 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
#else
__RCSID("$NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $");
__RCSID("$NetBSD: exec.c,v 1.55 2021/02/16 15:30:12 kre Exp $");
#endif
#endif /* not lint */
@ -683,6 +683,7 @@ loop:
if (act & DO_ERR)
outfmt(out2, "%s: %s\n", name, errmsg(e, E_EXEC));
entry->cmdtype = CMDUNKNOWN;
entry->u.index = idx + 1;
return;
builtin_success:
@ -704,8 +705,10 @@ success:
entry->lineno = cmdp->lineno;
entry->lno_frel = cmdp->fn_ln1;
entry->u = cmdp->param;
} else
} else {
entry->cmdtype = CMDUNKNOWN;
entry->u.index = -1;
}
}