gss_buffer_desc gssbuf;
OM_uint32 maj_status, min_status;
struct hostent *hostinfo = NULL;
- char *xhost;
+ char *xhost, *addr;
/* Make a copy of the host name, in case it was returned by a
* previous call to gethostbyname(). */
if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
debug("Unable to get FQDN for \"%s\"", xhost);
} else {
- xfree(xhost);
- xhost = xstrdup(hostinfo->h_name);
+ addr = xmalloc(hostinfo->h_length);
+ memcpy(addr, hostinfo->h_addr, hostinfo->h_length);
+ hostinfo = gethostbyaddr(addr, hostinfo->h_length, AF_INET);
+ xfree(addr);
+ if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
+ debug("Unable to get FQDN for \"%s\"", xhost);
+ } else {
+ xfree(xhost);
+ xhost = xstrdup(hostinfo->h_name);
+ }
}
gssbuf.length = sizeof("host@")+strlen(xhost);
int type;
char *gssapi_auth_type = NULL;
struct hostent *hostinfo;
-
+ char *addr;
/*
* host is not guarenteed to be a FQDN, so we need to make sure it is.
*/
hostinfo = gethostbyname(host);
+ if ((hostinfo == NULL) || (hostinfo->h_addr == NULL)) {
+ debug("GSSAPI authentication: Unable to get FQDN for \"%s\"", host);
+ goto cleanup;
+ }
+
+ addr = xmalloc(hostinfo->h_length);
+ memcpy(addr, hostinfo->h_addr, hostinfo->h_length);
+ hostinfo = gethostbyaddr(addr, hostinfo->h_length, AF_INET);
+ xfree(addr);
+
if ((hostinfo == NULL) || (hostinfo->h_name == NULL)) {
debug("GSSAPI authentication: Unable to get FQDN for \"%s\"", host);
goto cleanup;