1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00
* resolv/nsap_addr.c (inet_nsap_addr): Little optimization.

	* resolv/inet_ntop.c (inet_ntop4): Little optimization.
	(inet_ntop6): Likewise.
This commit is contained in:
Ulrich Drepper
1999-10-03 00:14:09 +00:00
parent 0c03cb9bed
commit fcb594165e
3 changed files with 10 additions and 8 deletions

View File

@@ -1,5 +1,10 @@
1999-10-02 Ulrich Drepper <drepper@cygnus.com> 1999-10-02 Ulrich Drepper <drepper@cygnus.com>
* resolv/nsap_addr.c (inet_nsap_addr): Little optimization.
* resolv/inet_ntop.c (inet_ntop4): Little optimization.
(inet_ntop6): Likewise.
* resolv/inet_net_pton.c (inet_net_pton_ipv4): Prevent buffer * resolv/inet_net_pton.c (inet_net_pton_ipv4): Prevent buffer
overruns. overruns.

View File

@@ -97,8 +97,7 @@ inet_ntop4(src, dst, size)
__set_errno (ENOSPC); __set_errno (ENOSPC);
return (NULL); return (NULL);
} }
strcpy(dst, tmp); return strcpy(dst, tmp);
return (dst);
} }
/* const char * /* const char *
@@ -132,8 +131,8 @@ inet_ntop6(src, dst, size)
* Find the longest run of 0x00's in src[] for :: shorthanding. * Find the longest run of 0x00's in src[] for :: shorthanding.
*/ */
memset(words, '\0', sizeof words); memset(words, '\0', sizeof words);
for (i = 0; i < IN6ADDRSZ; i++) for (i = 0; i < IN6ADDRSZ; i += 2)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); words[i / 2] = (src[i] << 8) | src[i + 1];
best.base = -1; best.base = -1;
cur.base = -1; cur.base = -1;
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
@@ -194,6 +193,5 @@ inet_ntop6(src, dst, size)
__set_errno (ENOSPC); __set_errno (ENOSPC);
return (NULL); return (NULL);
} }
strcpy(dst, tmp); return strcpy(dst, tmp);
return (dst);
} }

View File

@@ -60,8 +60,7 @@ inet_nsap_addr(ascii, binary, maxlen)
continue; continue;
if (!isascii(c)) if (!isascii(c))
return (0); return (0);
if (islower(c)) c = toupper(c);
c = toupper(c);
if (isxdigit(c)) { if (isxdigit(c)) {
nib = xtob(c); nib = xtob(c);
if ((c = *ascii++)) { if ((c = *ascii++)) {