From 65193a54609c558e473118dba323edc001bdb585 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Thu, 21 Oct 2021 13:11:35 -0700 Subject: Fix: attempted to access stale memory upon exec failure. Now correctly prints out argv[1] --- sys/cmd/rc/sys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys') diff --git a/sys/cmd/rc/sys.c b/sys/cmd/rc/sys.c index 86c430e..807359d 100644 --- a/sys/cmd/rc/sys.c +++ b/sys/cmd/rc/sys.c @@ -76,19 +76,19 @@ execute(Word *cmd, Word *path) nc = strlen(path->str); if(nc < arrlen(file)){ strcpy(file, path->str); - if(*file){ + if(file[0]){ strcat(file, "/"); nc++; } - if(nc+strlen(argv[1]) < 1024){ + if(nc+strlen(argv[1]) < arrlen(file)){ strcat(file, argv[1]); execve(file, argv+1, env); }else fatal("command name too long"); } } + print(shell.err, "could not execute command: %s\n", argv[1]); efree(argv); - fatal("could not execute command: %s\n", path->str); } void -- cgit v1.2.1