Skip to content

Commit 8111ed5

Browse files
author
henesy
committed
Fix that one spooky mk bug — mk: fix closing random fd from uninitialized stack variable (thanks BurnZeZ, mycroftiv)
1 parent 897ab09 commit 8111ed5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

utils/mk/Plan9.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ execsh(char *args, char *cmd, Bufblock *buf, Envy *e)
199199
perror(shell);
200200
_exits("exec");
201201
}
202-
close(out[1]);
202+
if(buf)
203+
close(out[1]);
203204
close(in[0]);
204205
p = cmd+strlen(cmd);
205206
while(cmd < p){

utils/mk/Posix.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ execsh(char *args, char *cmd, Bufblock *buf, Envy *e)
130130
perror(shell);
131131
_exits("exec");
132132
}
133-
close(out[1]);
133+
if(buf)
134+
close(out[1]);
134135
close(in[0]);
135136
if(DEBUG(D_EXEC))
136137
fprint(1, "starting: %s\n", cmd);

0 commit comments

Comments
 (0)