Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh PR bin/55979



details:   https://anonhg.NetBSD.org/src/rev/e18c4f8c6124
branches:  trunk
changeset: 959515:e18c4f8c6124
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Feb 16 15:30:12 2021 +0000

description:
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

diffstat:

 bin/sh/exec.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r 10aed453c316 -r e18c4f8c6124 bin/sh/exec.c
--- a/bin/sh/exec.c     Tue Feb 16 15:06:30 2021 +0000
+++ b/bin/sh/exec.c     Tue Feb 16 15:30:12 2021 +0000
@@ -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 @@
        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 @@
                entry->lineno = cmdp->lineno;
                entry->lno_frel = cmdp->fn_ln1;
                entry->u = cmdp->param;
-       } else
+       } else {
                entry->cmdtype = CMDUNKNOWN;
+               entry->u.index = -1;
+       }
 }
 
 



Home | Main Index | Thread Index | Old Index