mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
stack smashing
This commit is contained in:
17
userland/c/smash_stack.c
Normal file
17
userland/c/smash_stack.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/* https://cirosantilli.com/linux-kernel-module-cheat#stack-smashing */
|
||||
|
||||
void myfunc(char *const src, int len) {
|
||||
int i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
src[i] = 42;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
char arr[] = {'a', 'b', 'c', 'd'};
|
||||
int len = sizeof(arr);
|
||||
myfunc(arr, len);
|
||||
myfunc(arr, len + 1);
|
||||
myfunc(arr, len);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user