Update automatically managed build utilities.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 15 Apr 2016 18:53:37 +0000 (19:53 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 15 Apr 2016 18:53:37 +0000 (19:53 +0100)
Makefile
debian/changelog
noip.c

index b3360da..49a157c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,24 @@ man1dir                       = ${mandir}/man1
 DESTDIR                         =
 
 ###--------------------------------------------------------------------------
+### Quiet building.
+
+## Verbosity.
+V                       = 0
+
+## Compilation.
+V_CC                    = $(V_CC_$(V))$(CC)
+V_CC_0                  = @echo "  CC     $@";
+
+## Linking.
+V_LD                    = $(V_LD_$(V))$(LD)
+V_LD_0                  = @echo "  LD     $@";
+
+## Generation.
+V_GEN                   = $(V_GEN_$(V))
+V_GEN_0                         = @echo "  GEN    $@";
+
+###--------------------------------------------------------------------------
 ### Build parameters.
 
 ## Mess with these if you like.
@@ -124,21 +142,18 @@ clean:
 
 ## Building sources.
 %.o: %.c
-       $(CC) -c $(REAL_CFLAGS) $< -o $@
+       $(V_CC) -c $(REAL_CFLAGS) $< -o $@
 
 ## Constructing preload hacks.
 noip.so: $(patsubst %.c, %.o, $(NOIP_SOURCES))
-       $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
+       $(V_LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
 uopen.so: $(patsubst %.c, %.o, $(UOPEN_SOURCES))
-       $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
+       $(V_LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
 
 ## Constructing the scripts.
-$(SCRIPTS): withlib.in
-       for i in $(SCRIPTS); do \
-         sed "s/@lib@/$$i/" withlib.in >$$i.new || exit 1; \
-         chmod +x $$i.new || exit 1; \
-         mv $$i.new $$i || exit 1; \
-       done
+$(SCRIPTS): %: withlib.in
+       $(V_GEN)sed "s/@lib@/$@/" withlib.in >$@.new && \
+               chmod +x $@.new && mv $@.new $@
 
 ###--------------------------------------------------------------------------
 ### Installation.
index dc8b9a8..f16f09c 100644 (file)
@@ -1,3 +1,10 @@
+preload-hacks (1.0.6) experimental; urgency=low
+
+  * Fix premature strlen(3) call in decode_inet_addr.
+  * Various internal changes.
+
+ -- Mark Wooding <mdw@distorted.org.uk>  Mon, 14 Jun 2010 01:27:30 +0100
+
 preload-hacks (1.0.5) experimental; urgency=low
 
   * Fix `errno' clobbering in connect(2).
diff --git a/noip.c b/noip.c
index 237bfd0..9f82e25 100644 (file)
--- a/noip.c
+++ b/noip.c
@@ -98,10 +98,9 @@ static aclnode *connect_real,  **connect_tail = &connect_real;
   _(sendto, ssize_t, (int, const void *buf, size_t, int,               \
                      const struct sockaddr *to, socklen_t tolen))      \
   _(recvfrom, ssize_t, (int, void *buf, size_t, int,                   \
-                       struct sockaddr *from, socklen_t *fromlen))     \
+                       struct sockaddr *from, socklen_t *fromlen))     \
   _(sendmsg, ssize_t, (int, const struct msghdr *, int))               \
-  _(recvmsg, ssize_t, (int, struct msghdr *, int))                     \
-  _(close, int, (int))
+  _(recvmsg, ssize_t, (int, struct msghdr *, int))
 
 /* Function pointers to set up. */
 #define DECL(imp, ret, args) static ret (*real_##imp) args;
@@ -266,7 +265,7 @@ static int unix_socket_status(struct sockaddr_un *sun, int quickp)
   rc = USED;
   if ((fp = fopen("/proc/net/unix", "r")) == 0)
     goto done;
-  fgets(buf, sizeof(buf), fp); /* skip header */
+  if (!fgets(buf, sizeof(buf), fp)) goto done; /* skip header */
   len = strlen(sun->sun_path);
   while (fgets(buf, sizeof(buf), fp)) {
     n = strlen(buf);
@@ -352,7 +351,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 +359,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); )
@@ -440,7 +440,7 @@ static int fixup_real_ip_socket(int sk)
   len = sizeof(ov_);                                                   \
   if (real_getsockopt(sk, SOL_SOCKET, SO_##opt, &ov_, &len) < 0 ||     \
       real_setsockopt(nsk, SOL_SOCKET, SO_##opt, &ov_, len)) {         \
-    real_close(nsk);                                                   \
+    close(nsk);                                                                \
     return (-1);                                                       \
   }                                                                    \
 } while (0);
@@ -450,11 +450,11 @@ static int fixup_real_ip_socket(int sk)
       (fd = fcntl(sk, F_GETFD)) < 0 ||
       fcntl(nsk, F_SETFL, f) < 0 ||
       dup2(nsk, sk) < 0) {
-    real_close(nsk);
+    close(nsk);
     return (-1);
   }
   unlink(sun.sun_path);
-  real_close(nsk);
+  close(nsk);
   if (fcntl(sk, F_SETFD, fd) < 0) {
     perror("noip: fixup_real_ip_socket F_SETFD");
     abort();
@@ -1090,7 +1090,7 @@ static void get_local_ipaddrs(void)
     return;
   for (i = n_local_ipaddrs = 0;
        n_local_ipaddrs < MAX_LOCAL_IPADDRS &&
-         ifn[i].if_name && *ifn[i].if_name;
+        ifn[i].if_name && *ifn[i].if_name;
        i++) {
     strcpy(ifr.ifr_name, ifn[i].if_name);
     if (ioctl(sk, SIOCGIFADDR, &ifr) || ifr.ifr_addr.sa_family != AF_INET)
@@ -1104,7 +1104,8 @@ static void get_local_ipaddrs(void)
 }
 
 /* Print the given message to standard error.  Avoids stdio. */
-static void printerr(const char *p) { write(STDERR_FILENO, p, strlen(p)); }
+static void printerr(const char *p)
+  { int hunoz; hunoz = write(STDERR_FILENO, p, strlen(p)); }
 
 /* Create the socket directory, being careful about permissions. */
 static void create_sockdir(void)