noip.c (unix_socket_status): Refactor status-file parsing.
[preload-hacks] / noip.c
diff --git a/noip.c b/noip.c
index 68b4978..9dfc6c3 100644 (file)
--- 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);