optionsfrom: Properly handle errors when determining file size

This commit is contained in:
Tobias Brunner
2014-07-02 12:38:45 +02:00
parent e44223dbcc
commit 831045ef45
+7 -2
View File
@@ -90,8 +90,13 @@ METHOD(options_t, from, bool,
}
/* determine the file size */
fseek(fd, 0, SEEK_END);
src.len = ftell(fd);
if (fseek(fd, 0, SEEK_END) == -1 || (src.len = ftell(fd)) == -1)
{
DBG1(DBG_LIB, "optionsfrom: unable to determine size of '%s': %s",
filename, strerror(errno));
fclose(fd);
return FALSE;
}
rewind(fd);
/* allocate one byte more just in case of a missing final newline */