From: EunBong Song Date: Tue, 4 Jul 2017 04:11:26 +0000 (+0900) Subject: libc netdb: gethostbyname_r: Fix check for space in buffer. X-Git-Tag: 1.1_Public_Release~318^2~74 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c2ccc947df8eda13c0675f16e640cadc92b7cc3;p=rtos%2Ftinyara.git libc netdb: gethostbyname_r: Fix check for space in buffer. This patch comes from Nuttx commit id: ee7217be Change-Id: Ifc2b1973978b1b16e7fa1795a6009717bd67aa51 Signed-off-by: EunBong Song --- diff --git a/lib/libc/netdb/lib_gethostbyaddrr.c b/lib/libc/netdb/lib_gethostbyaddrr.c index 6c08e22..a2653ef 100644 --- a/lib/libc/netdb/lib_gethostbyaddrr.c +++ b/lib/libc/netdb/lib_gethostbyaddrr.c @@ -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; } diff --git a/lib/libc/netdb/lib_gethostbynamer.c b/lib/libc/netdb/lib_gethostbynamer.c index d23649d..3928b7d 100644 --- a/lib/libc/netdb/lib_gethostbynamer.c +++ b/lib/libc/netdb/lib_gethostbynamer.c @@ -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; }