Do one in-bounds write in clean runs of stacksmash.c
This commit is contained in:
1 parent
461f889187
commit
03b99b5144
1 file changed
+4
-3
+4
-3
@@ -19,8 +19,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
__attribute__((noinline))
|
__attribute__((noinline))
|
||||||
void func(char *ptr) {
|
void func(char *ptr, int idx) {
|
||||||
ptr[10] = 0;
|
ptr[idx] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@@ -28,8 +28,9 @@ int main(int argc, char *argv[]) {
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
fprintf(stderr, "smashing stack\n");
|
fprintf(stderr, "smashing stack\n");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
func(buf);
|
func(buf, 10);
|
||||||
} else {
|
} else {
|
||||||
|
func(buf, 9);
|
||||||
fprintf(stderr, "%s: A test tool for detecting stack smashing.\n"
|
fprintf(stderr, "%s: A test tool for detecting stack smashing.\n"
|
||||||
"Run this with a command line argument to trigger an "
|
"Run this with a command line argument to trigger an "
|
||||||
"error.\n", argv[0]);
|
"error.\n", argv[0]);
|
||||||
|
|||||||
Reference in new issue
Block a user