commit 8fc14fd702897e652a38384af2f55e51752e8c15 Author: Alexey Melnikov Date: Tue May 29 16:00:47 2012 +0100 get_fqhostname() function has broken logic when abort_if_no_fqdn is 0 When abort_if_no_fqdn is 0, a getaddrinfo failure should be ignored, as long as gethostname() succeeded. Cyrus SASL Bug # 3589 Patch by baggins@pld-linux.org diff --git a/lib/saslutil.c b/lib/saslutil.c index fc5b774..6174124 100644 --- a/lib/saslutil.c +++ b/lib/saslutil.c @@ -557,32 +557,44 @@ int get_fqhostname( NULL, /* don't care abour service/port */ &hints, &result) != 0) { - /* errno on Unix, WSASetLastError on Windows are already done by the function */ - return (-1); + if (abort_if_no_fqdn) { + /* errno on Unix, WSASetLastError on Windows are already done by the function */ + return (-1); + } else { + goto LOWERCASE; + } } - if (abort_if_no_fqdn && (result == NULL || result->ai_canonname == NULL)) { + if (result == NULL || result->ai_canonname == NULL) { freeaddrinfo (result); + if (abort_if_no_fqdn) { #ifdef WIN32 - WSASetLastError (WSANO_DATA); + WSASetLastError (WSANO_DATA); #elif defined(ENODATA) - errno = ENODATA; + errno = ENODATA; #elif defined(EADDRNOTAVAIL) - errno = EADDRNOTAVAIL; + errno = EADDRNOTAVAIL; #endif - return (-1); + return (-1); + } else { + goto LOWERCASE; + } } - if (abort_if_no_fqdn && strchr (result->ai_canonname, '.') == NULL) { + if (strchr (result->ai_canonname, '.') == NULL) { freeaddrinfo (result); + if (abort_if_no_fqdn) { #ifdef WIN32 - WSASetLastError (WSANO_DATA); + WSASetLastError (WSANO_DATA); #elif defined(ENODATA) - errno = ENODATA; + errno = ENODATA; #elif defined(EADDRNOTAVAIL) - errno = EADDRNOTAVAIL; + errno = EADDRNOTAVAIL; #endif - return (-1); + return (-1); + } else { + goto LOWERCASE; + } }