diff options
Diffstat (limited to 'src/plugins/ipmi_intf.c')
| -rw-r--r-- | src/plugins/ipmi_intf.c | 27 | 
1 files changed, 20 insertions, 7 deletions
| diff --git a/src/plugins/ipmi_intf.c b/src/plugins/ipmi_intf.c index 0fa76be..a84237e 100644 --- a/src/plugins/ipmi_intf.c +++ b/src/plugins/ipmi_intf.c @@ -194,15 +194,14 @@ struct ipmi_intf * ipmi_intf_load(char * name)  void  ipmi_intf_session_set_hostname(struct ipmi_intf * intf, char * hostname)  { -	if (intf->session == NULL) +	if (intf->session == NULL || hostname == NULL) {  		return; - -	memset(intf->session->hostname, 0, 16); - -	if (hostname != NULL) { -		memcpy(intf->session->hostname, hostname, -		       __min(strlen(hostname), 64));  	} +	if (intf->session->hostname != NULL) { +		free(intf->session->hostname); +		intf->session->hostname = NULL; +	} +	intf->session->hostname = strdup(hostname);  }  void @@ -331,6 +330,20 @@ ipmi_intf_session_set_retry(struct ipmi_intf * intf, int retry)  }  void +ipmi_intf_session_cleanup(struct ipmi_intf *intf) +{ +	if (intf->session == NULL) { +		return; +	} +	if (intf->session->hostname != NULL) { +		free(intf->session->hostname); +		intf->session->hostname = NULL; +	} +	free(intf->session); +	intf->session = NULL; +} + +void  ipmi_cleanup(struct ipmi_intf * intf)  {  	ipmi_sdr_list_empty(intf); | 
