diff options
Diffstat (limited to 'src/lib/libc/net/getnameinfo.c')
| -rw-r--r-- | src/lib/libc/net/getnameinfo.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/lib/libc/net/getnameinfo.c b/src/lib/libc/net/getnameinfo.c index 0906686fa6..0dee5a6c4c 100644 --- a/src/lib/libc/net/getnameinfo.c +++ b/src/lib/libc/net/getnameinfo.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: getnameinfo.c,v 1.18 2000/09/25 22:52:57 itojun Exp $ */ | 1 | /* $OpenBSD: getnameinfo.c,v 1.19 2001/08/20 02:23:33 itojun Exp $ */ |
| 2 | /* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */ | 2 | /* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */ |
| 3 | 3 | ||
| 4 | /* | 4 | /* |
| @@ -315,17 +315,18 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags) | |||
| 315 | char scopebuf[MAXHOSTNAMELEN]; | 315 | char scopebuf[MAXHOSTNAMELEN]; |
| 316 | int scopelen; | 316 | int scopelen; |
| 317 | 317 | ||
| 318 | /* ip6_sa2str never fails */ | 318 | scopelen = ip6_sa2str( |
| 319 | scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa, | 319 | (const struct sockaddr_in6 *)(const void *)sa, |
| 320 | scopebuf, sizeof(scopebuf), | 320 | scopebuf, sizeof(scopebuf), 0); |
| 321 | flags); | 321 | if (scopelen < 0) |
| 322 | return ENI_MEMORY; | ||
| 322 | if (scopelen + 1 + numaddrlen + 1 > hostlen) | 323 | if (scopelen + 1 + numaddrlen + 1 > hostlen) |
| 323 | return ENI_MEMORY; | 324 | return ENI_MEMORY; |
| 324 | /* | 325 | /* |
| 325 | * construct <numeric-addr><delim><scopeid> | 326 | * construct <numeric-addr><delim><scopeid> |
| 326 | */ | 327 | */ |
| 327 | memcpy(host + numaddrlen + 1, scopebuf, | 328 | memcpy(host + numaddrlen + 1, scopebuf, |
| 328 | scopelen); | 329 | (size_t)scopelen); |
| 329 | host[numaddrlen] = SCOPE_DELIMITER; | 330 | host[numaddrlen] = SCOPE_DELIMITER; |
| 330 | host[numaddrlen + 1 + scopelen] = '\0'; | 331 | host[numaddrlen + 1 + scopelen] = '\0'; |
| 331 | } | 332 | } |
| @@ -343,12 +344,20 @@ ip6_sa2str(sa6, buf, bufsiz, flags) | |||
| 343 | size_t bufsiz; | 344 | size_t bufsiz; |
| 344 | int flags; | 345 | int flags; |
| 345 | { | 346 | { |
| 346 | unsigned int ifindex = (unsigned int)sa6->sin6_scope_id; | 347 | unsigned int ifindex; |
| 347 | const struct in6_addr *a6 = &sa6->sin6_addr; | 348 | const struct in6_addr *a6; |
| 349 | int n; | ||
| 350 | |||
| 351 | ifindex = (unsigned int)sa6->sin6_scope_id; | ||
| 352 | a6 = &sa6->sin6_addr; | ||
| 348 | 353 | ||
| 349 | #ifdef notyet | 354 | #ifdef notdef |
| 350 | if (flags & NI_NUMERICSCOPE) { | 355 | if ((flags & NI_NUMERICSCOPE) != 0) { |
| 351 | return(snprintf(buf, bufsiz, "%d", sa6->sin6_scope_id)); | 356 | n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); |
| 357 | if (n < 0 || n >= bufsiz) | ||
| 358 | return -1; | ||
| 359 | else | ||
| 360 | return n; | ||
| 352 | } | 361 | } |
| 353 | #endif | 362 | #endif |
| 354 | 363 | ||
| @@ -362,6 +371,10 @@ ip6_sa2str(sa6, buf, bufsiz, flags) | |||
| 362 | } | 371 | } |
| 363 | 372 | ||
| 364 | /* last resort */ | 373 | /* last resort */ |
| 365 | return(snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id)); | 374 | n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); |
| 375 | if (n < 0 || n >= bufsiz) | ||
| 376 | return -1; | ||
| 377 | else | ||
| 378 | return n; | ||
| 366 | } | 379 | } |
| 367 | #endif /* INET6 */ | 380 | #endif /* INET6 */ |
