parse_leases: exit at read error upstream-head
authorSami Kerola <sami.kerola@tomtom.com>
Thu, 23 Jun 2011 13:59:06 +0000 (15:59 +0200)
committerSami Kerola <sami.kerola@tomtom.com>
Thu, 23 Jun 2011 13:59:06 +0000 (15:59 +0200)
Signed-off-by: Sami Kerola <sami.kerola@tomtom.com>

src/getdata.c

index 2c5e627..b0a3f5c 100644 (file)
@@ -130,7 +130,9 @@ int parse_leases(void)
        }
 
        while (!feof(dhcpd_leases)) {
-               fgets(line, MAXLEN, dhcpd_leases);
+               if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) {
+                       err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file);
+               }
                /* It's a lease, save IP */
                if (strstr(line, "lease") == line) {
                        strncpy(ipstring, line, (size_t) MAXLEN);