dns: implement tcp fallback in __res_msend query core
[musl] / src / network / gethostbyaddr_r.c
index 66e0330..ceaf393 100644 (file)
@@ -54,9 +54,10 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
        case EAI_OVERFLOW:
                return ERANGE;
        default:
-       case EAI_MEMORY:
-       case EAI_SYSTEM:
        case EAI_FAIL:
+               *err = NO_RECOVERY;
+               return EBADMSG;
+       case EAI_SYSTEM:
                *err = NO_RECOVERY;
                return errno;
        case 0:
@@ -64,6 +65,7 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
        }
 
        h->h_addrtype = af;
+       h->h_length = l;
        h->h_name = h->h_aliases[0];
        *res = h;
        return 0;