Module Name: src
Committed By: kre
Date: Tue Feb 16 15:30:12 UTC 2021
Modified Files:
src/bin/sh: exec.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/bin/sh/exec.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/exec.c
diff -u src/bin/sh/exec.c:1.54 src/bin/sh/exec.c:1.55
--- src/bin/sh/exec.c:1.54 Sat Aug 1 17:51:18 2020
+++ src/bin/sh/exec.c Tue Feb 16 15:30:12 2021
@@ -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;
+ }
}