shithub: purgatorio

Download patch

ref: babf901b4a508c3ec5d1f89655f10377bbdf9637
parent: 06fac9885c8349fe2e06ffdd36817f65adc0fd66
author: henesy <devnull@localhost>
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);