Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/net PR/50195: Henning Petersen: Incorrect check in ...



details:   https://anonhg.NetBSD.org/src/rev/397d7b36bb4b
branches:  trunk
changeset: 340414:397d7b36bb4b
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Sep 03 15:01:19 2015 +0000

description:
PR/50195: Henning Petersen: Incorrect check in getnameinfo_link.

diffstat:

 lib/libc/net/getnameinfo.c |  22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diffs (57 lines):

diff -r 2ae2bb6518b5 -r 397d7b36bb4b lib/libc/net/getnameinfo.c
--- a/lib/libc/net/getnameinfo.c        Thu Sep 03 14:23:52 2015 +0000
+++ b/lib/libc/net/getnameinfo.c        Thu Sep 03 15:01:19 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getnameinfo.c,v 1.56 2015/05/15 14:26:02 joerg Exp $   */
+/*     $NetBSD: getnameinfo.c,v 1.57 2015/09/03 15:01:19 christos Exp $        */
 /*     $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $    */
 
 /*
@@ -47,7 +47,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getnameinfo.c,v 1.56 2015/05/15 14:26:02 joerg Exp $");
+__RCSID("$NetBSD: getnameinfo.c,v 1.57 2015/09/03 15:01:19 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #ifndef RUMP_ACTION
@@ -536,11 +536,7 @@
 
        if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) {
                n = snprintf(host, hostlen, "link#%u", sdl->sdl_index);
-               if (n < 0 || (socklen_t) n > hostlen) {
-                       *host = '\0';
-                       return EAI_MEMORY;
-               }
-               return 0;
+               goto out;
        }
 
        switch (sdl->sdl_type) {
@@ -553,11 +549,7 @@
                else
                        n = snprintf(host, hostlen, "%u.%u",
                            CLLADDR(sdl)[1], CLLADDR(sdl)[0]);
-               if (n < 0 || (socklen_t) n >= hostlen) {
-                       *host = '\0';
-                       return EAI_MEMORY;
-               } else
-                       return 0;
+               goto out;
 #endif
        case IFT_IEEE1394:
                if (sdl->sdl_alen < sizeof(iha->iha_uid))
@@ -591,6 +583,12 @@
                return hexname((const uint8_t *)CLLADDR(sdl),
                    (size_t)sdl->sdl_alen, host, hostlen);
        }
+out:
+       if (n < 0 || (socklen_t) n >= hostlen) {
+               *host = '\0';
+               return EAI_MEMORY;
+       }
+       return 0;
 }
 
 static int



Home | Main Index | Thread Index | Old Index