cfg/ini.cpp: Fix buffer overflow in ConfigFile::parse()

This commit is contained in:
Jan Holthuis 2016-02-22 18:33:09 +01:00
parent 2866c879ac
commit 5638b872ac
1 changed files with 5 additions and 1 deletions

View File

@ -221,7 +221,11 @@ void ConfigFile::parse(FILE* file)
if (tl[0] == '[' && tl[strlen(tl)-1] == ']') if (tl[0] == '[' && tl[strlen(tl)-1] == ']')
{ {
tl[strlen(tl)-1] = '\0'; tl[strlen(tl)-1] = '\0';
strcpy(current_section, tl+1);
// FIXME: Data loss if buffer is too small
strncpy(current_section, tl+1, sizeof(current_section));
current_section[sizeof(current_section) - 1] = '\0';
trim_ws(current_section); trim_ws(current_section);
} }
else else