|
Buffer Overflow
Buffer overflows are
usually categorized according to the memory region in which the
overflow occurs. The stack area of memory serves a variety of
purposes, such as passing arguments to functions, storing local
variables, and keeping track of where execution should return to
when the current function is finished executing.
Example of a Stack Overflow
void
func(char *str)
{
char name[64];
strcpy(name,str);
printf("Hello, %s\n",name);
}
int
main(int argc, char **argv)
{
if(argc < 2) {
printf("Usage: %s name\n",argv[0]);
return –1;
}
func(argv[1]);
return 0;
} |