From 38f3573e0ee1628ef694367f8bc153daa970cf34 Mon Sep 17 00:00:00 2001 From: Mihnea Gheorghe Date: Mon, 10 Nov 2025 23:09:44 +0200 Subject: [PATCH] data/bypassing-stack-protector: Fix canary overwrite Solution now suggests overwriting the canary of the current stack frame instead of 2 up Signed-off-by: Mihnea Gheorghe --- .../solution/src/stack_protector.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/chapters/data/memory-security/drills/tasks/bypassing-stack-protector/solution/src/stack_protector.c b/chapters/data/memory-security/drills/tasks/bypassing-stack-protector/solution/src/stack_protector.c index f93b49b25b..68b2e26f2c 100644 --- a/chapters/data/memory-security/drills/tasks/bypassing-stack-protector/solution/src/stack_protector.c +++ b/chapters/data/memory-security/drills/tasks/bypassing-stack-protector/solution/src/stack_protector.c @@ -19,12 +19,15 @@ void fun1(char *p) } printf("overwrite canary:\n"); - /* TODO 1: Add code that overwrites the canary. */ - addr[6] = 0; + /* TODO 1: Add code that overwrites the canary. + * Note: You should get a stack smashing detected error. + * Remove the overwrite after getting the error in order to proceed to the next step. + */ + addr[1] = 0; printf("overwrite return address:\n"); /* TODO 2: Add code that overwrites the return address with the address of pawned. */ - addr[7] = &pawned; + addr[3] = &pawned; (void) p; }