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 */
|
/* determine the file size */
|
||||||
fseek(fd, 0, SEEK_END);
|
if (fseek(fd, 0, SEEK_END) == -1 || (src.len = ftell(fd)) == -1)
|
||||||
src.len = ftell(fd);
|
{
|
||||||
|
DBG1(DBG_LIB, "optionsfrom: unable to determine size of '%s': %s",
|
||||||
|
filename, strerror(errno));
|
||||||
|
fclose(fd);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
rewind(fd);
|
rewind(fd);
|
||||||
|
|
||||||
/* allocate one byte more just in case of a missing final newline */
|
/* allocate one byte more just in case of a missing final newline */
|
||||||
|
|||||||
Reference in New Issue
Block a user