diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2021-10-21 13:11:35 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2021-10-21 13:11:35 -0700 |
commit | 65193a54609c558e473118dba323edc001bdb585 (patch) | |
tree | 6984e90522add407b072cf88e558371e0064f8a4 /sys/cmd | |
parent | 79fb5e6be113678d4ef0349d2e584f219e567426 (diff) |
Fix: attempted to access stale memory upon exec failure.
Now correctly prints out argv[1]
Diffstat (limited to 'sys/cmd')
-rw-r--r-- | sys/cmd/rc/sys.c | 6 |
1 files changed, 3 insertions, 3 deletions
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 |