Skip to content
Snippets Groups Projects
Commit f5eb635f authored by 20041679's avatar 20041679
Browse files

fixed buffer overflow due to improper use of fscanf

parent 249ec0c1
No related branches found
No related tags found
No related merge requests found
......@@ -12,14 +12,20 @@ typedef struct {
Person person_read(FILE *f) {
Person person;
// FIXME: buffer overflow
char format[5 + 5 + 3];
sprintf(
format, "%%%zus%%%zus%%hu",
ARR_LEN(person.first_name),
ARR_LEN(person.last_name)
);
fscanf(
f, "%s %s %hu\n",
f, format,
person.first_name,
person.last_name,
&person.age
);
return person;
}
void person_print(FILE *f, Person person) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment