summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2024-01-05 06:46:35 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2024-01-05 06:46:35 +0000
commit8d2b84747b1cbc54d6f23cc461d3ef838c1dfec9 (patch)
treefae48e759e89d889f155dbd76c6db5d7de42ef62
parent2ca3934809cc51fed6a386eb13f67f08fd89fdf2 (diff)
ip/ppp: fix race condition with rfork()
ipinprocpid is static so shared with parent and child, so we need a temporary variable on the local stack to properly assign ipinprocpid.
-rw-r--r--sys/src/cmd/ip/ppp/ppp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/src/cmd/ip/ppp/ppp.c b/sys/src/cmd/ip/ppp/ppp.c
index 970d5cf5a..634c5df96 100644
--- a/sys/src/cmd/ip/ppp/ppp.c
+++ b/sys/src/cmd/ip/ppp/ppp.c
@@ -1640,7 +1640,7 @@ static char*
ipopen(PPP *ppp)
{
static int ipinprocpid;
- int n, cfd, fd;
+ int n, cfd, fd, pid;
char path[128];
char buf[128];
@@ -1676,7 +1676,7 @@ ipopen(PPP *ppp)
close(cfd);
ppp->ipfd = fd;
- switch(ipinprocpid = rfork(RFPROC|RFMEM|RFNOWAIT)){
+ switch(pid = rfork(RFPROC|RFMEM|RFNOWAIT)){
case -1:
terminate(ppp, "forking ipinproc", 1);
case 0:
@@ -1684,6 +1684,7 @@ ipopen(PPP *ppp)
terminate(ppp, "ipinproc", 0);
exits(nil);
}
+ ipinprocpid = pid;
if(validv4(ppp->local)){
if(!validv4(ppp->remote))