Ive got 2 example codes, one is safe against buffer overflows even compiled with
gcc -fno-stack-protector -fno-pie -m32 save.c -o save
Code of safe program:
#include <stdio.h>
char check[16];
int main(int argc, char **argv) {
printf("Enter a string: ");
gets(check);
printf("%s\n", check);
printf("Accepted.\n");
}
Code of unsafe (vulnerable) program:
#include <stdio.h>
int main(int argc, char **argv) {
char check[16];
printf("Enter a string: ");
gets(check);
printf("%s\n", check);
printf("Accepted.\n");
}
Why is the char outside the program "safe"? (in my case)