Trap fgets() failure in *_scan()
Ensure we don't read arbitrary data when fgets() returns a NULL string (meaning that either the EOF is encountered or an error occurred). This also fixes a couple of compiler warnings seen with "-Wunused-result". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
@@ -149,7 +149,9 @@ event_scan (FILE *f, struct tm start, int id, char *note)
|
||||
localtime (&t);
|
||||
|
||||
/* Read the event description */
|
||||
fgets (buf, sizeof buf, f);
|
||||
if (!fgets (buf, sizeof buf, f))
|
||||
return NULL;
|
||||
|
||||
nl = strchr (buf, '\n');
|
||||
if (nl)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user