diff options
author | itojun <> | 2000-04-26 16:08:12 +0000 |
---|---|---|
committer | itojun <> | 2000-04-26 16:08:12 +0000 |
commit | d47d69094415cb5dac0309bc93f57573e10acd24 (patch) | |
tree | b707720e46c50bb2a191636bdba807758643a62c /src/lib | |
parent | 22ad87b0af500f86de2f25c0114aa2286e9b56d2 (diff) | |
download | openbsd-d47d69094415cb5dac0309bc93f57573e10acd24.tar.gz openbsd-d47d69094415cb5dac0309bc93f57573e10acd24.tar.bz2 openbsd-d47d69094415cb5dac0309bc93f57573e10acd24.zip |
const poisoning
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/net/getnameinfo.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/libc/net/getnameinfo.c b/src/lib/libc/net/getnameinfo.c index 33e628c623..673ead74ba 100644 --- a/src/lib/libc/net/getnameinfo.c +++ b/src/lib/libc/net/getnameinfo.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* $OpenBSD: getnameinfo.c,v 1.13 2000/04/26 14:46:47 itojun Exp $ */ | 1 | /* $OpenBSD: getnameinfo.c,v 1.14 2000/04/26 16:08:12 itojun Exp $ */ |
2 | /* $KAME: getnameinfo.c,v 1.38 2000/04/26 15:58:50 itojun Exp $ */ | ||
2 | 3 | ||
3 | /* | 4 | /* |
4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 5 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. |
@@ -85,9 +86,9 @@ struct sockinet { | |||
85 | }; | 86 | }; |
86 | 87 | ||
87 | #ifdef INET6 | 88 | #ifdef INET6 |
88 | static int ip6_parsenumeric __P((const struct sockaddr *, char *, char *, | 89 | static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *, |
89 | int, int)); | 90 | size_t, int)); |
90 | static int ip6_sa2str __P((struct sockaddr_in6 *, char *, size_t, int)); | 91 | static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int)); |
91 | #endif | 92 | #endif |
92 | 93 | ||
93 | #define ENI_NOSOCKET 0 | 94 | #define ENI_NOSOCKET 0 |
@@ -113,7 +114,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) | |||
113 | struct hostent *hp; | 114 | struct hostent *hp; |
114 | u_short port; | 115 | u_short port; |
115 | int family, i; | 116 | int family, i; |
116 | char *addr; | 117 | const char *addr; |
117 | u_int32_t v4a; | 118 | u_int32_t v4a; |
118 | int h_error; | 119 | int h_error; |
119 | char numserv[512]; | 120 | char numserv[512]; |
@@ -137,8 +138,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) | |||
137 | if (salen != afd->a_socklen) | 138 | if (salen != afd->a_socklen) |
138 | return ENI_SALEN; | 139 | return ENI_SALEN; |
139 | 140 | ||
140 | port = ((struct sockinet *)sa)->si_port; /* network byte order */ | 141 | /* network byte order */ |
141 | addr = (char *)sa + afd->a_off; | 142 | port = ((const struct sockinet *)sa)->si_port; |
143 | addr = (const char *)sa + afd->a_off; | ||
142 | 144 | ||
143 | if (serv == NULL || servlen == 0) { | 145 | if (serv == NULL || servlen == 0) { |
144 | /* | 146 | /* |
@@ -169,7 +171,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) | |||
169 | switch (sa->sa_family) { | 171 | switch (sa->sa_family) { |
170 | case AF_INET: | 172 | case AF_INET: |
171 | v4a = (u_int32_t) | 173 | v4a = (u_int32_t) |
172 | ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr); | 174 | ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr); |
173 | if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) | 175 | if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) |
174 | flags |= NI_NUMERICHOST; | 176 | flags |= NI_NUMERICHOST; |
175 | v4a >>= IN_CLASSA_NSHIFT; | 177 | v4a >>= IN_CLASSA_NSHIFT; |
@@ -179,8 +181,8 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) | |||
179 | #ifdef INET6 | 181 | #ifdef INET6 |
180 | case AF_INET6: | 182 | case AF_INET6: |
181 | { | 183 | { |
182 | struct sockaddr_in6 *sin6; | 184 | const struct sockaddr_in6 *sin6; |
183 | sin6 = (struct sockaddr_in6 *)sa; | 185 | sin6 = (const struct sockaddr_in6 *)sa; |
184 | switch (sin6->sin6_addr.s6_addr[0]) { | 186 | switch (sin6->sin6_addr.s6_addr[0]) { |
185 | case 0x00: | 187 | case 0x00: |
186 | if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) | 188 | if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) |
@@ -249,6 +251,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) | |||
249 | * implemented here - see RFC2553 p30 | 251 | * implemented here - see RFC2553 p30 |
250 | */ | 252 | */ |
251 | if (flags & NI_NOFQDN) { | 253 | if (flags & NI_NOFQDN) { |
254 | char *p; | ||
252 | p = strchr(hp->h_name, '.'); | 255 | p = strchr(hp->h_name, '.'); |
253 | if (p) | 256 | if (p) |
254 | *p = '\0'; | 257 | *p = '\0'; |
@@ -289,8 +292,10 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) | |||
289 | static int | 292 | static int |
290 | ip6_parsenumeric(sa, addr, host, hostlen, flags) | 293 | ip6_parsenumeric(sa, addr, host, hostlen, flags) |
291 | const struct sockaddr *sa; | 294 | const struct sockaddr *sa; |
292 | char *addr, *host; | 295 | const char *addr; |
293 | int flags, hostlen; | 296 | char *host; |
297 | size_t hostlen; | ||
298 | int flags; | ||
294 | { | 299 | { |
295 | int numaddrlen; | 300 | int numaddrlen; |
296 | char numaddr[512]; | 301 | char numaddr[512]; |
@@ -305,14 +310,14 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags) | |||
305 | strcpy(host, numaddr); | 310 | strcpy(host, numaddr); |
306 | 311 | ||
307 | #ifdef NI_WITHSCOPEID | 312 | #ifdef NI_WITHSCOPEID |
308 | if (((struct sockaddr_in6 *)sa)->sin6_scope_id) { | 313 | if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) { |
309 | if (flags & NI_WITHSCOPEID) | 314 | if (flags & NI_WITHSCOPEID) |
310 | { | 315 | { |
311 | char scopebuf[MAXHOSTNAMELEN]; | 316 | char scopebuf[MAXHOSTNAMELEN]; |
312 | int scopelen; | 317 | int scopelen; |
313 | 318 | ||
314 | /* ip6_sa2str never fails */ | 319 | /* ip6_sa2str never fails */ |
315 | scopelen = ip6_sa2str((struct sockaddr_in6 *)sa, | 320 | scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa, |
316 | scopebuf, sizeof(scopebuf), | 321 | scopebuf, sizeof(scopebuf), |
317 | 0); | 322 | 0); |
318 | if (scopelen + 1 + numaddrlen + 1 > hostlen) | 323 | if (scopelen + 1 + numaddrlen + 1 > hostlen) |
@@ -334,13 +339,13 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags) | |||
334 | /* ARGSUSED */ | 339 | /* ARGSUSED */ |
335 | static int | 340 | static int |
336 | ip6_sa2str(sa6, buf, bufsiz, flags) | 341 | ip6_sa2str(sa6, buf, bufsiz, flags) |
337 | struct sockaddr_in6 *sa6; | 342 | const struct sockaddr_in6 *sa6; |
338 | char *buf; | 343 | char *buf; |
339 | size_t bufsiz; | 344 | size_t bufsiz; |
340 | int flags; | 345 | int flags; |
341 | { | 346 | { |
342 | unsigned int ifindex = (unsigned int)sa6->sin6_scope_id; | 347 | unsigned int ifindex = (unsigned int)sa6->sin6_scope_id; |
343 | struct in6_addr *a6 = &sa6->sin6_addr; | 348 | const struct in6_addr *a6 = &sa6->sin6_addr; |
344 | 349 | ||
345 | #ifdef notyet | 350 | #ifdef notyet |
346 | if (flags & NI_NUMERICSCOPE) { | 351 | if (flags & NI_NUMERICSCOPE) { |