code: 9ferno

Download patch

ref: 8111ed57c545908b8028b7cb45126af70c4586e6
parent: 897ab0913d20930339f244c3ee031b53a229747d
author: henesy <unknown>
date: Sun Apr 5 18:58:08 EDT 2020

Fix that one spooky mk bug — mk: fix closing random fd from uninitialized stack variable (thanks BurnZeZ, mycroftiv)

--- a/utils/mk/Plan9.c
+++ b/utils/mk/Plan9.c
@@ -199,7 +199,8 @@
 			perror(shell);
 			_exits("exec");
 		}
-		close(out[1]);
+		if(buf)
+			close(out[1]);
 		close(in[0]);
 		p = cmd+strlen(cmd);
 		while(cmd < p){
--- a/utils/mk/Posix.c
+++ b/utils/mk/Posix.c
@@ -130,7 +130,8 @@
 			perror(shell);
 			_exits("exec");
 		}
-		close(out[1]);
+		if(buf)
+			close(out[1]);
 		close(in[0]);
 		if(DEBUG(D_EXEC))
 			fprint(1, "starting: %s\n", cmd);