Skip to contentSkip to conversation

pass a valid stack address to clone(2)

PATCH/cr_tests Applied Nathan Lynch 2 participants 2 messages Sep 1, 2009 – Sep 2, 2009 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Off-by-one error: the stack address passed to clone() must be within the region allocated.

---
 ns_exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ns_exec.c +1 -1
index 09574e2..1f61771 100644
@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
 			perror("malloc");
 			return -1;
 		}
-		childstack = stack + stacksize;
+		childstack = stack + stacksize - 1;
 
 		printf("about to clone with %lx\n", flags);
 		flags |= SIGCHLD;
Signature · 1 line
1.6.0.6
#2 lore raw
In reply to a message not in the archive
Quoted 4 lines · Nathan Lynch

Off-by-one error: the stack address passed to clone() must be within the region allocated.

Applied, thanks.

Quoted 21 lines
---
 ns_exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ns_exec.c +1 -1
index 09574e2..1f61771 100644
@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
 			perror("malloc");
 			return -1;
 		}
-		childstack = stack + stacksize;
+		childstack = stack + stacksize - 1;
 
 		printf("about to clone with %lx\n", flags);
 		flags |= SIGCHLD;
Signature · 1 line
1.6.0.6