From 61fbb4a5be3eea4c5e6def5c0d7cc6ef9a5f79ec Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 9 Jun 2018 15:52:12 +0100 Subject: [PATCH] noip.c (unix_socket_status): Refactor status-file parsing. Remove the early exit: we always process all of the entries now. The socket is `STALE' if we can't find any entries. --- noip.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/noip.c b/noip.c index 68b4978..9dfc6c3 100644 --- a/noip.c +++ b/noip.c @@ -704,15 +704,17 @@ static int unix_socket_status(struct sockaddr_un *sun, int quickp) goto done; if (!fgets(buf, sizeof(buf), fp)) goto done; /* skip header */ len = strlen(sun->sun_path); + rc = 0; while (fgets(buf, sizeof(buf), fp)) { n = strlen(buf); if (n >= len + 2 && buf[n - len - 2] == ' ' && buf[n - 1] == '\n' && - memcmp(buf + n - len - 1, sun->sun_path, len) == 0) - goto done; + memcmp(buf + n - len - 1, sun->sun_path, len) == 0) { + rc |= USED; + } } if (ferror(fp)) goto done; - rc = STALE; + if (!rc) rc = STALE; done: if (fp) fclose(fp); -- 2.11.0