The program below allows the occurrence of memory overflow, because it is possible to override the variable zero by placing a "large" value in the variable buffer
. How to make a secure program by avoiding buffer overflow ?
#include <stdio.h>
main(){
char buffer[8];
int zero = 0;
gets(buffer);
puts(buffer);
if(zero == 0){
printf("Zero continua sendo zero");
}else{
printf("A variavel zero foi modificada");
}
return 0;
}