summaryrefslogtreecommitdiffstats
path: root/avahi-daemon/static-hosts.c
diff options
context:
space:
mode:
Diffstat (limited to 'avahi-daemon/static-hosts.c')
-rw-r--r--avahi-daemon/static-hosts.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/avahi-daemon/static-hosts.c b/avahi-daemon/static-hosts.c
index aba96f7..23d5384 100644
--- a/avahi-daemon/static-hosts.c
+++ b/avahi-daemon/static-hosts.c
@@ -171,46 +171,52 @@ void static_hosts_load(int in_chroot) {
line++;
- /* Find the start of the line, ignore whitespace */
- s = ln + strspn(ln, " \t");
- /* Set the end of the string to NULL */
- s[strcspn(s, "#\r\n")] = 0;
-
- /* Ignore comment (#) and blank lines (*/
- if (*s == '#' || *s == 0)
- continue;
-
- /* Read the first string (ip) up to the next whitespace */
- len = strcspn(s, " \t");
- ip = avahi_strndup(s, len);
-
- /* Skip past it */
- s += len;
-
- /* Find the next token */
- s += strspn(s, " \t");
- len = strcspn(s, " \t");
- host = avahi_strndup(s, len);
-
- if (*host == 0)
- {
- avahi_log_error ("%s:%d: Error, unexpected end of line!", filename, line);
- break;
- }
+ /* Find the start of the line, ignore whitespace */
+ s = ln + strspn(ln, " \t");
+ /* Set the end of the string to NULL */
+ s[strcspn(s, "#\r\n")] = 0;
+
+ /* Ignore comment (#) and blank lines (*/
+ if (*s == '#' || *s == 0)
+ continue;
+
+ /* Read the first string (ip) up to the next whitespace */
+ len = strcspn(s, " \t");
+ ip = avahi_strndup(s, len);
+
+ /* Skip past it */
+ s += len;
+
+ /* Find the next token */
+ s += strspn(s, " \t");
+ len = strcspn(s, " \t");
+ host = avahi_strndup(s, len);
+
+ if (*host == 0)
+ {
+ avahi_log_error("%s:%d: Error, unexpected end of line!", filename, line);
+ avahi_free(host);
+ avahi_free(ip);
+ break;
+ }
/* Skip past any more spaces */
- s += strspn(s+len, " \t");
+ s += strspn(s+len, " \t");
/* Anything left? */
- if (*(s+len) != 0) {
- avahi_log_error ("%s:%d: Junk on the end of the line!", filename, line);
+ if (*(s+len) != 0) {
+ avahi_log_error ("%s:%d: Junk on the end of the line!", filename, line);
+ avahi_free(host);
+ avahi_free(ip);
break;
- }
+ }
h = static_host_new();
h->host = host;
h->ip = ip;
}
+
+ fclose(f);
}
void static_hosts_free_all (void)