ref: ef96a954c006fb47b92530a05f9c9c3e01b3b492
parent: 6ede09d80281467684cef159697b88e1f87277c1
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 7 09:49:12 EST 2020
lib9p: improve reqqueuecreate() - open /proc/n/ctl with OCEXEC flag - format pid as ulong - don't leak the fd
--- a/sys/src/lib9p/queue.c
+++ b/sys/src/lib9p/queue.c
@@ -16,8 +16,8 @@
q = v;
rfork(RFNOTEG);
- buf = smprint("/proc/%d/ctl", getpid());- fd = open(buf, OWRITE);
+ buf = smprint("/proc/%lud/ctl", (ulong)getpid());+ fd = open(buf, OWRITE|OCEXEC);
free(buf);
for(;;){@@ -40,6 +40,8 @@
f(r);
}
+ if(fd >= 0)
+ close(fd);
free(r);
free(q);
threadexits(nil);
--
⑨