Do one in-bounds write in clean runs of stacksmash.c

This commit is contained in:
Martin Storsjö committed 2018-10-07 21:00:30 +03:00
1 parent 461f889187
commit 03b99b5144
1 file changed
+4 -3
+4 -3
View File
@@ -19,8 +19,8 @@
#include <stdio.h>
__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]);