optionsfrom: Properly handle errors when determining file size
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user