Permalink
Browse files

sunos: add getaddrinfo() compatibility hack

getaddrinfo() returns EAI_MEMORY if strlen(hostname) >= MAXHOSTNAMELEN
  • Loading branch information...
bnoordhuis committed Nov 10, 2011
1 parent 04dfd46 commit 26806e2b1c63e8090c261fb3f48f0d36e4bb4445
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/unix/core.c
View
@@ -589,6 +589,10 @@ int64_t uv_timer_get_repeat(uv_timer_t* timer) {
static int uv_getaddrinfo_done(eio_req* req) {
uv_getaddrinfo_t* handle = req->data;
struct addrinfo *res = handle->res;
+#if __sun
+ size_t hostlen = strlen(handle->hostname);
+#endif
+
handle->res = NULL;
uv_unref(handle->loop);
@@ -605,6 +609,10 @@ static int uv_getaddrinfo_done(eio_req* req) {
} else if (handle->retcode == EAI_NONAME) {
#endif
uv__set_sys_error(handle->loop, ENOENT); /* FIXME compatibility hack */
+#if __sun
+ } else if (handle->retcode == EAI_MEMORY && hostlen >= MAXHOSTNAMELEN) {
+ uv__set_sys_error(handle->loop, ENOENT);
+#endif
} else {
handle->loop->last_err.code = UV_EADDRINFO;
handle->loop->last_err.sys_errno_ = handle->retcode;

0 comments on commit 26806e2

Please sign in to comment.