libc netdb: gethostbyname_r: Fix check for space in buffer.
authorEunBong Song <eunb.song@samsung.com>
Tue, 4 Jul 2017 04:11:26 +0000 (13:11 +0900)
committerEunBong Song <eunb.song@samsung.com>
Wed, 30 Aug 2017 04:15:43 +0000 (21:15 -0700)
This patch comes from Nuttx commit id: ee7217be

Change-Id: Ifc2b1973978b1b16e7fa1795a6009717bd67aa51
Signed-off-by: EunBong Song <eunb.song@samsung.com>
lib/libc/netdb/lib_gethostbyaddrr.c
lib/libc/netdb/lib_gethostbynamer.c

index 6c08e22..a2653ef 100644 (file)
@@ -213,7 +213,7 @@ static int lib_localhost(FAR const void *addr, socklen_t len, int type, FAR stru
        /* And copy localhost host name */
 
        namelen = strlen(g_lo_hostname);
-       if (addrlen + namelen + 1 > buflen) {
+       if ((namelen + 1) > buflen) {
                herrnocode = ERANGE;
                goto errorout_with_herrnocode;
        }
index d23649d..3928b7d 100644 (file)
@@ -215,7 +215,7 @@ static int lib_numeric_address(FAR const char *name, FAR struct hostent *host, F
        /* And copy name */
 
        namelen = strlen(name);
-       if (addrlen + namelen + 1 > buflen) {
+       if ((namelen + 1) > buflen) {
                return -ERANGE;
        }
 
@@ -403,7 +403,7 @@ static int lib_find_answer(FAR const char *name, FAR struct hostent *host, FAR c
        /* And copy the host name */
 
        namelen = strlen(name);
-       if (addrlen + namelen + 1 > buflen) {
+       if ((namelen + 1) > buflen) {
                return -ERANGE;
        }
 
@@ -539,7 +539,7 @@ static int lib_dns_lookup(FAR const char *name, FAR struct hostent *host, FAR ch
                /* And copy name */
 
                namelen = strlen(name);
-               if (addrlen + namelen + 1 > buflen) {
+               if ((namelen + 1) > buflen) {
                        return -ERANGE;
                }