openhpi/openhpi-3.8.0-ipv6-ipmidirect.patch
DistroBaker 2936effdff Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/openhpi.git#1b7c880836c4d104f6b95ed6e9833a877cf38e16
2020-12-16 22:13:45 +00:00

49 lines
1.8 KiB
Diff

diff --git a/plugins/ipmidirect/ipmi.cpp b/plugins/ipmidirect/ipmi.cpp
index f6745cf6..3b4918de 100644
--- a/plugins/ipmidirect/ipmi.cpp
+++ b/plugins/ipmidirect/ipmi.cpp
@@ -1929,7 +1929,12 @@ cIpmi::AllocConnection( GHashTable *handler_config )
char user[32] = "";
char passwd[32] = "";
char *value;
- struct hostent *ent;
+ struct addrinfo hints, *servinfo = NULL;
+ char portnumber_string[4];
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
// Address
addr = (const char *)g_hash_table_lookup(handler_config, "addr");
@@ -1941,16 +1946,16 @@ cIpmi::AllocConnection( GHashTable *handler_config )
}
stdlog << "AllocConnection: addr = '" << addr << "'.\n";
- ent = gethostbyname( addr );
+ (void)sprintf(portnumber_string, "%d", lan_port);
- if ( !ent )
+ if (getaddrinfo(addr, portnumber_string, &hints, &servinfo) != 0)
{
stdlog << "Unable to resolve IPMI LAN address: " << addr << " !\n";
return 0;
}
- memcpy( &lan_addr, ent->h_addr_list[0], ent->h_length );
- unsigned int a = *(unsigned int *)(void *)ent->h_addr_list[0];
+ memcpy(&lan_addr, servinfo->ai_addr, servinfo->ai_addrlen);
+ unsigned int a = *(unsigned int *)(void *)servinfo->ai_addr;
stdlog << "Using host at "
<< (int)(a & 0xff) << "."
@@ -1958,6 +1963,8 @@ cIpmi::AllocConnection( GHashTable *handler_config )
<< (int)((a >> 16) & 0xff) << "."
<< (int)((a >> 24) & 0xff) << ".\n";
+ freeaddrinfo(servinfo);
+
// Port
lan_port = GetIntNotNull( handler_config, "port", 623 );