FreeBSD Bugzilla – Attachment 62071 Details for
Bug 92880
[libc] [patch] almost rewritten inet_network(3) function
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.75 KB, created by
Andrey Simonenko
on 2006-02-06 07:00:14 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Andrey Simonenko
Created:
2006-02-06 07:00:14 UTC
Size:
1.75 KB
patch
obsolete
>--- inet_network.c.orig Fri Mar 22 23:52:29 2002 >+++ inet_network.c Sun Feb 5 22:21:14 2006 >@@ -48,48 +48,58 @@ > * network numbers. > */ > in_addr_t >-inet_network(cp) >- const char *cp; >+inet_network(const char *cp) > { >- in_addr_t val, base, n; >- char c; >- in_addr_t parts[4], *pp = parts; >- int i; >+ u_char c; >+ int got_data; >+ u_int base, dots; >+ in_addr_t res, val; >+ >+ res = 0; >+ dots = 0; > > again: >- val = 0; base = 10; >- if (*cp == '0') >- base = 8, cp++; >- if (*cp == 'x' || *cp == 'X') >- base = 16, cp++; >- while ((c = *cp) != 0) { >- if (isdigit((unsigned char)c)) { >- val = (val * base) + (c - '0'); >- cp++; >- continue; >- } >- if (base == 16 && isxdigit((unsigned char)c)) { >- val = (val << 4) + (c + 10 - (islower((unsigned char)c) ? 'a' : 'A')); >+ val = 0; >+ got_data = 0; >+ if (*cp == '0') { >+ cp++; >+ if (*cp == 'x' || *cp == 'X') { > cp++; >- continue; >+ base = 16; >+ } else { >+ base = 8; >+ got_data = 1; > } >- break; >+ } else >+ base = 10; >+ while ((c = *cp) != '\0') { >+ if (isdigit(c)) { >+ if (base == 8 && c > '7') >+ return (INADDR_NONE); >+ val = val * base + c - '0'; >+ } else if (base == 16 && isxdigit(c)) >+ val = (val << 4) + 10 - (islower(c) ? 'a' : 'A'); >+ else >+ break; >+ if (val > 0xff) >+ return (INADDR_NONE); >+ cp++; >+ got_data = 1; > } >- if (*cp == '.') { >- if (pp >= parts + 3) >+ if (!got_data) >+ return (INADDR_NONE); >+ if (dots != 0) >+ res <<= 8; >+ res |= val; >+ if (c == '.') { >+ if (++dots == 4) > return (INADDR_NONE); >- *pp++ = val, cp++; >+ cp++; > goto again; > } >- if (*cp && !isspace((unsigned char)*cp)) >+ if (c != '\0') > return (INADDR_NONE); >- *pp++ = val; >- n = pp - parts; >- for (val = 0, i = 0; i < n; i++) { >- val <<= 8; >- val |= parts[i] & 0xff; >- } >- return (val); >+ return (res); > } > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 92880
: 62071