diff --git a/lib/krb5/addr_families.c b/lib/krb5/addr_families.c index b33582e69..c5cc07993 100644 --- a/lib/krb5/addr_families.c +++ b/lib/krb5/addr_families.c @@ -530,6 +530,7 @@ krb5_parse_address(krb5_context context, int i, n; struct addrinfo *ai, *a; int error; + int save_errno; for(i = 0; i < num_addrs; i++) { if(at[i].parse_addr) { @@ -544,8 +545,9 @@ krb5_parse_address(krb5_context context, error = getaddrinfo (string, NULL, NULL, &ai); if (error) { + save_errno = errno; krb5_set_error_string (context, "%s: %s", string, gai_strerror(error)); - return krb5_eai_to_heim_errno(error); + return krb5_eai_to_heim_errno(error, save_errno); } n = 0; diff --git a/lib/krb5/changepw.c b/lib/krb5/changepw.c index 9312fb88c..6baff7a2e 100644 --- a/lib/krb5/changepw.c +++ b/lib/krb5/changepw.c @@ -46,6 +46,7 @@ get_kdc_address (krb5_context context, int port = 0; int error; char *host; + int save_errno; ret = krb5_get_krb_changepw_hst (context, &realm, @@ -64,9 +65,10 @@ get_kdc_address (krb5_context context, error = roken_getaddrinfo_hostspec2(host, SOCK_DGRAM, port, ai); if(error) { + save_errno = errno; krb5_set_error_string(context, "resolving %s: %s", host, gai_strerror(error)); - return krb5_eai_to_heim_errno(error); + return krb5_eai_to_heim_errno(error, save_errno); } *ret_host = host; return 0; diff --git a/lib/krb5/get_for_creds.c b/lib/krb5/get_for_creds.c index 3093d7e5c..0ae82f510 100644 --- a/lib/krb5/get_for_creds.c +++ b/lib/krb5/get_for_creds.c @@ -141,15 +141,17 @@ krb5_get_forwarded_creds (krb5_context context, krb5_kdc_flags kdc_flags; krb5_crypto crypto; struct addrinfo *ai; + int save_errno; addrs.len = 0; addrs.val = NULL; ret = getaddrinfo (hostname, NULL, NULL, &ai); if (ret) { + save_errno = errno; krb5_set_error_string(context, "resolving %s: %s", hostname, gai_strerror(ret)); - return krb5_eai_to_heim_errno(ret); + return krb5_eai_to_heim_errno(ret, save_errno); } ret = add_addrs (context, &addrs, ai); diff --git a/lib/krb5/send_to_kdc.c b/lib/krb5/send_to_kdc.c index 5e1ecd9e9..9fa325cf6 100644 --- a/lib/krb5/send_to_kdc.c +++ b/lib/krb5/send_to_kdc.c @@ -267,7 +267,7 @@ send_via_proxy (krb5_context context, ret = getaddrinfo (proxy, portstr, &hints, &ai); free (proxy2); if (ret) - return krb5_eai_to_heim_errno(ret); + return krb5_eai_to_heim_errno(ret, errno); for (a = ai; a != NULL; a = a->ai_next) { s = socket (a->ai_family, a->ai_socktype, a->ai_protocol);