noip.c: Make sure it's an AF_UNIX address before counting the length.
[preload-hacks] / noip.c
diff --git a/noip.c b/noip.c
index bcba77f..06a07c6 100644 (file)
--- a/noip.c
+++ b/noip.c
@@ -352,7 +352,7 @@ static int decode_inet_addr(struct sockaddr_in *sin,
 {
   char buf[INET_ADDRSTRLEN + 16];
   char *p;
-  size_t n = strlen(sockdir), nn = strlen(sun->sun_path);
+  size_t n = strlen(sockdir), nn;
   struct sockaddr_in sin_mine;
   unsigned long port;
 
@@ -360,6 +360,7 @@ static int decode_inet_addr(struct sockaddr_in *sin,
     sin = &sin_mine;
   if (sun->sun_family != AF_UNIX)
     return (-1);
+  nn = strlen(sun->sun_path);
   if (len < sizeof(sun)) ((char *)sun)[len] = 0;
   D( fprintf(stderr, "noip: decode (%d) `%s'",
             *sun->sun_path, sun->sun_path); )