shithub: purgatorio

Download patch

ref: babf901b4a508c3ec5d1f89655f10377bbdf9637
parent: 06fac9885c8349fe2e06ffdd36817f65adc0fd66
author: henesy <devnull@localhost>
date: Mon Apr 6 01: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	Sat Feb 29 19:34:34 2020
+++ b/utils/mk/Plan9.c	Mon Apr  6 01:58:08 2020
@@ -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	Sat Feb 29 19:34:34 2020
+++ b/utils/mk/Posix.c	Mon Apr  6 01:58:08 2020
@@ -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);