summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspew <devnull@localhost>2016-05-01 20:34:07 -0500
committerspew <devnull@localhost>2016-05-01 20:34:07 -0500
commitee68dedf53695895630fd9a463429a8d34a9679c (patch)
treed6a3058eba10cc7c8d48d7d21292c885fa7734ce
parenta141f4c53a32d8227f9a490a8e4f7d87445c47d1 (diff)
null terminate await buffer for proper tokenize call
-rw-r--r--sys/src/cmd/awk/run.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/src/cmd/awk/run.c b/sys/src/cmd/awk/run.c
index e288f881f..d3244de1c 100644
--- a/sys/src/cmd/awk/run.c
+++ b/sys/src/cmd/awk/run.c
@@ -63,7 +63,7 @@ int
system(const char *s)
{
char status[512], *statfld[5];
- int w, pid;
+ int n, pid;
if(!s)
return 1; /* a command interpreter is available */
@@ -76,8 +76,9 @@ system(const char *s)
return -1;
}
for(;;) {
- w = await(status, sizeof(status) - 1);
- if(w == -1)
+ n = await(status, sizeof(status) - 1);
+ status[n] = '\0';
+ if(n == -1)
return -1;
tokenize(status, statfld, nelem(statfld));
if(strtol(statfld[0], nil, 0) == pid)