fixed a dumb buffer overflow i think
This commit is contained in:
parent
b208382e60
commit
f5e5c506af
@ -215,19 +215,19 @@ void loadFiles()
|
|||||||
char *x = fgets(buff, 255, fp);
|
char *x = fgets(buff, 255, fp);
|
||||||
if (buff[0] == '/' && buff[1] == '/' || buff[0] == '\n')
|
if (buff[0] == '/' && buff[1] == '/' || buff[0] == '\n')
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(buff, "Segment") || !strcmp(buff, "Route") || x == NULL)
|
if (!strcmp(buff, "Segment\n") || !strcmp(buff, "Route\n") || x == NULL)
|
||||||
break;
|
break;
|
||||||
fgets(buff2, 255, fp);
|
fgets(buff2, 255, fp);
|
||||||
if (buff2[0] == '\t') {
|
if (buff2[0] == '\t') {
|
||||||
valuecount++;
|
valuecount++;
|
||||||
|
|
||||||
names = realloc(names, sizeof(char*) * valuecount);
|
names = realloc(names, sizeof(char*) * valuecount);
|
||||||
names[valuecount - 1] = malloc(strlen(buff) - 1);
|
names[valuecount - 1] = malloc(strlen(buff));
|
||||||
strncpy(names[valuecount - 1], buff, strlen(buff) - 1);
|
strncpy(names[valuecount - 1], buff, strlen(buff) - 1);
|
||||||
names[valuecount - 1][strlen(buff)] = '\0';
|
names[valuecount - 1][strlen(buff)] = '\0';
|
||||||
|
|
||||||
values = realloc(values, sizeof(char*) * valuecount);
|
values = realloc(values, sizeof(char*) * valuecount);
|
||||||
values[valuecount - 1] = malloc(strlen(buff2) - 2);
|
values[valuecount - 1] = malloc(strlen(buff2) - 1);
|
||||||
strncpy(values[valuecount - 1], buff2 + 1, strlen(buff2) - 1);
|
strncpy(values[valuecount - 1], buff2 + 1, strlen(buff2) - 1);
|
||||||
values[valuecount - 1][strlen(buff2)] = '\0';
|
values[valuecount - 1][strlen(buff2)] = '\0';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user