From 03b99b51445fe81b711acf3dc21e38e823476120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 7 Oct 2018 21:00:30 +0300 Subject: [PATCH] Do one in-bounds write in clean runs of stacksmash.c --- test/stacksmash.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/stacksmash.c b/test/stacksmash.c index a5b4523..019b1c3 100644 --- a/test/stacksmash.c +++ b/test/stacksmash.c @@ -19,8 +19,8 @@ #include __attribute__((noinline)) -void func(char *ptr) { - ptr[10] = 0; +void func(char *ptr, int idx) { + ptr[idx] = 0; } int main(int argc, char *argv[]) { @@ -28,8 +28,9 @@ int main(int argc, char *argv[]) { if (argc > 1) { fprintf(stderr, "smashing stack\n"); fflush(stderr); - func(buf); + func(buf, 10); } else { + func(buf, 9); fprintf(stderr, "%s: A test tool for detecting stack smashing.\n" "Run this with a command line argument to trigger an " "error.\n", argv[0]);