chiark
/
gitweb
/
~mdw
/
preload-hacks
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
noip.c (encode_single_inet_addr): Make the logic less weird.
[preload-hacks]
/
noip.c
diff --git
a/noip.c
b/noip.c
index 68b4978cf986129bddfa777be131bbbee471c581..fea6f742adaac68c2299016c9857b3b31e1c0630 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);
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' &&
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;
}
if (ferror(fp))
goto done;
- rc = STALE;
+
if (!rc)
rc = STALE;
done:
if (fp) fclose(fp);
done:
if (fp) fclose(fp);
@@
-732,9
+734,9
@@
static int encode_single_inet_addr(const struct sockaddr *sa,
snprintf(sun->sun_path, sizeof(sun->sun_path), "%s/%s", sockdir,
present_sockaddr(sa, 0, buf, sizeof(buf)));
snprintf(sun->sun_path, sizeof(sun->sun_path), "%s/%s", sockdir,
present_sockaddr(sa, 0, buf, sizeof(buf)));
-
if ((rc = unix_socket_status(sun, quickp)) == USED) return (USED
);
-
else
if (rc == STALE) unlink(sun->sun_path);
- return (
UNUSED
);
+
rc = unix_socket_status(sun, quickp
);
+ if (rc == STALE) unlink(sun->sun_path);
+ return (
rc
);
}
/* Convert the IP address SA to a Unix-domain address SUN. Fail if the
}
/* Convert the IP address SA to a Unix-domain address SUN. Fail if the