void fvuln(char
*
str1, char
*
str2,
int
age)
{
int
local_age;
char
buffer
[
64
];
char
*
ptr
=
malloc(
1024
);
char
*
ptr1
=
malloc(
1024
);
char
*
ptr2
=
malloc(
1024
);
char
*
ptr3;
local_age
=
age;
strncpy(
buffer
, str1, sizeof(
buffer
)
-
1
);
printf(
"\nptr found at [ %p ]"
, ptr);
printf(
"\nptr1ovf found at [ %p ]"
, ptr1);
printf(
"\nptr2ovf found at [ %p ]\n"
, ptr2);
printf(
"Enter a description: "
);
fread(ptr,
1024
*
5
,
1
, stdin);
free(ptr1);
printf(
"\nEND free(1)\n"
);
free(ptr2);
printf(
"\nEND free(2)\n"
);
ptr3
=
malloc(
1024
);
printf(
"\nEND malloc()\n"
);
strncpy(ptr3, str2,
1024
-
1
);
printf(
"Your name is %s and you are %d"
,
buffer
, local_age);
}
int
main(
int
argc, char
*
argv[])
{
if
(argc <
4
) {
printf(
"Usage: ./hop name last-name age"
);
exit(
0
);
}
fvuln(argv[
1
], argv[
2
], atoi(argv[
3
]));
return
0
;
}