Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: avoid using enam after popheap() in bin_dot



---

Duplicating the warning print section is a bit ugly, patches welcome if
you have a better idea.

This was originally sent to zsh-security but me and Oliver judged it is
not a security issue. An attacker would need to control PATH anyway, and
even then we're not writing to anything.

 Src/builtin.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Src/builtin.c b/Src/builtin.c
index 64a27511fa..e901fcc119 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -6090,6 +6090,16 @@ bin_dot(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    break;
 		}
 	    }
+	    if (ret == SOURCE_NOT_FOUND) {
+		/* we have to use enam before popheap() */
+		if (isset(POSIXBUILTINS)) {
+		    /* hard error in POSIX (we'll exit later) */
+		    zerrnam(name, "%e: %s", errno, enam);
+		} else {
+		    zwarnnam(name, "%e: %s", errno, enam);
+		}
+		enam = NULL;
+	    }
 	    popheap();
 	}
     }
@@ -6098,7 +6108,7 @@ bin_dot(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 	freearray(pparams);
 	pparams = old;
     }
-    if (ret == SOURCE_NOT_FOUND) {
+    if (ret == SOURCE_NOT_FOUND && enam) {
 	if (isset(POSIXBUILTINS)) {
 	    /* hard error in POSIX (we'll exit later) */
 	    zerrnam(name, "%e: %s", errno, enam);
-- 
2.38.1





Messages sorted by: Reverse Date, Date, Thread, Author