From 55031e72e6c02b4ae63e9052bad1a4b40002ac18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 1 Dec 2014 12:15:48 +0100 Subject: Imported Upstream version 1.8.15 --- src/plugins/ipmi_intf.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/plugins/ipmi_intf.c') 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 @@ -330,6 +329,20 @@ ipmi_intf_session_set_retry(struct ipmi_intf * intf, int retry) intf->session->retry = 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) { -- cgit v1.2.3