mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
Return EAI_OVERFLOW instead of EAI_MEMORY when the supplied buffer is
too short. This conforms to RFC3493, POSIX and XPG6. Obtained from: NetBSD
This commit is contained in:
parent
d808369aa1
commit
734aa10414
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=158790
@ -168,9 +168,10 @@ struct addrinfo {
|
||||
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
|
||||
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
||||
#define EAI_SYSTEM 11 /* system error returned in errno */
|
||||
#define EAI_BADHINTS 12
|
||||
#define EAI_PROTOCOL 13
|
||||
#define EAI_MAX 14
|
||||
#define EAI_BADHINTS 12 /* invalid value for hints */
|
||||
#define EAI_PROTOCOL 13 /* resolved protocol is unknown */
|
||||
#define EAI_OVERFLOW 14 /* argument buffer overflow */
|
||||
#define EAI_MAX 15
|
||||
|
||||
/*
|
||||
* Flag values for getaddrinfo()
|
||||
|
@ -63,6 +63,8 @@ memory allocation failure
|
||||
or
|
||||
.Fa servname
|
||||
not provided, or not known
|
||||
.It Dv EAI_OVERFLOW
|
||||
argument buffer overflow
|
||||
.It Dv EAI_PROTOCOL
|
||||
resolved protocol is unknown
|
||||
.It Dv EAI_SERVICE
|
||||
|
@ -48,7 +48,8 @@ static const char *ai_errlist[] = {
|
||||
"ai_socktype not supported", /* EAI_SOCKTYPE */
|
||||
"System error returned in errno", /* EAI_SYSTEM */
|
||||
"Invalid value for hints", /* EAI_BADHINTS */
|
||||
"Resolved protocol is unknown" /* EAI_PROTOCOL */
|
||||
"Resolved protocol is unknown", /* EAI_PROTOCOL */
|
||||
"Argument buffer overflow" /* EAI_OVERFLOW */
|
||||
};
|
||||
|
||||
const char *
|
||||
|
@ -280,7 +280,7 @@ ip6_parsenumeric(const struct sockaddr *sa, const char *addr,
|
||||
|
||||
numaddrlen = strlen(numaddr);
|
||||
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
|
||||
return EAI_MEMORY;
|
||||
return EAI_OVERFLOW;
|
||||
strlcpy(host, numaddr, hostlen);
|
||||
|
||||
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
|
||||
@ -291,9 +291,9 @@ ip6_parsenumeric(const struct sockaddr *sa, const char *addr,
|
||||
(const struct sockaddr_in6 *)(const void *)sa,
|
||||
zonebuf, sizeof(zonebuf), flags);
|
||||
if (zonelen < 0)
|
||||
return EAI_MEMORY;
|
||||
return EAI_OVERFLOW;
|
||||
if (zonelen + 1 + numaddrlen + 1 > hostlen)
|
||||
return EAI_MEMORY;
|
||||
return EAI_OVERFLOW;
|
||||
|
||||
/* construct <numeric-addr><delim><zoneid> */
|
||||
memcpy(host + numaddrlen + 1, zonebuf,
|
||||
|
Loading…
Reference in New Issue
Block a user