fix(libScePosixForWebKit): use FreeBSD's gai_strerror message texts
gai_strerror returned its own wording for most codes, so a resolver
failure was described with text FreeBSD's libc does not use: EAI_NONAME
(8) gave "Name or service not known" instead of "hostname nor servname
provided, or not known", EAI_BADFLAGS (3) "Invalid flags" instead of
"Invalid value for ai_flags", and an unknown code "Unknown address
resolution error" instead of "Unknown error". Twelve of the fifteen
texts differed.
FreeBSD 11.4, lib/libc/net/gai_strerror.c:
static const char *ai_errlist[] = {
"Success", /* 0 */
"Address family for hostname not supported", /* 1 */
"Temporary failure in name resolution", /* EAI_AGAIN */
"Invalid value for ai_flags", /* EAI_BADFLAGS */
"Non-recoverable failure in name resolution", /* EAI_FAIL */
"ai_family not supported", /* EAI_FAMILY */
"Memory allocation failure", /* EAI_MEMORY */
"No address associated with hostname", /* 7 */
"hostname nor servname provided, or not known", /* EAI_NONAME */
"servname not supported for ai_socktype", /* EAI_SERVICE */
"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 */
"Argument buffer overflow" /* EAI_OVERFLOW */
};
...
if (ecode >= 0 && ecode < EAI_MAX)
return ai_errlist[ecode];
return "Unknown error";
The table and the unknown-code text now match, as 5830d8e44 did for
strerror.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d371ed3076
commit
30d1e85283
|
|
@ -284,13 +284,13 @@ int APS5_VABI getnameinfo_nid_postfix(const void* address, std::uint32_t length,
|
|||
const char* APS5_VABI gai_strerror_nid_postfix(int error) {
|
||||
static const char* messages[] = {
|
||||
"Success", "Address family for hostname not supported", "Temporary failure in name resolution",
|
||||
"Invalid flags", "Name resolution failed", "Address family not supported",
|
||||
"Memory allocation failed", "No address for hostname", "Name or service not known",
|
||||
"Service not supported for socket type", "Socket type not supported", "System error",
|
||||
"Invalid hints", "Unknown protocol", "Buffer too small"
|
||||
"Invalid value for ai_flags", "Non-recoverable failure in name resolution", "ai_family not supported",
|
||||
"Memory allocation failure", "No address associated with hostname", "hostname nor servname provided, or not known",
|
||||
"servname not supported for ai_socktype", "ai_socktype not supported", "System error returned in errno",
|
||||
"Invalid value for hints", "Resolved protocol is unknown", "Argument buffer overflow"
|
||||
};
|
||||
if (error < 0 || error >= static_cast<int>(sizeof(messages) / sizeof(messages[0])))
|
||||
return "Unknown address resolution error";
|
||||
return "Unknown error";
|
||||
return messages[error];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,8 +113,13 @@ int main() {
|
|||
Require(getnameinfo_nid_postfix(v4.data(), 2, host, sizeof(host), nullptr, 0, 10) == 5);
|
||||
Require(getnameinfo_nid_postfix(v4.data(), v4.size(), host, sizeof(host), nullptr, 0, 32) == 3);
|
||||
Require(getnameinfo_nid_postfix(v4.data(), v4.size(), host, 1, nullptr, 0, 10) == 14);
|
||||
Require(std::strlen(gai_strerror_nid_postfix(14)) > 0);
|
||||
Require(std::strstr(gai_strerror_nid_postfix(-1), "Unknown") != nullptr);
|
||||
Require(std::strcmp(gai_strerror_nid_postfix(0), "Success") == 0);
|
||||
Require(std::strcmp(gai_strerror_nid_postfix(3), "Invalid value for ai_flags") == 0);
|
||||
Require(std::strcmp(gai_strerror_nid_postfix(8), "hostname nor servname provided, or not known") == 0);
|
||||
Require(std::strcmp(gai_strerror_nid_postfix(10), "ai_socktype not supported") == 0);
|
||||
Require(std::strcmp(gai_strerror_nid_postfix(14), "Argument buffer overflow") == 0);
|
||||
Require(std::strcmp(gai_strerror_nid_postfix(-1), "Unknown error") == 0);
|
||||
Require(std::strcmp(gai_strerror_nid_postfix(15), "Unknown error") == 0);
|
||||
GuestResolver::AddressInfo hints{};
|
||||
hints.flags = 12; // numeric host and service: no external DNS dependency
|
||||
hints.socketType = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue