From: Victor Julien Date: Thu, 30 Jan 2014 15:08:20 +0000 (+0100) Subject: util-host-os-info: scan build fixes X-Git-Tag: suricata-2.0rc1~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6474bd6bf3a74865ae7c37dffcc759fc8cf4475;p=thirdparty%2Fsuricata.git util-host-os-info: scan build fixes util-host-os-info.c:200:13: warning: Potential leak of memory pointed to by 'ip_str' SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./util-debug.h:278:35: note: expanded from macro 'SCLogError' #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./util-debug.h:214:82: note: expanded from macro 'SCLogErr' char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \ ^~ util-host-os-info.c:200:13: warning: Potential leak of memory pointed to by 'user_data' SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./util-debug.h:278:35: note: expanded from macro 'SCLogError' #define SCLogError(err_code, ...) SCLogErr(SC_LOG_ERROR, err_code, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./util-debug.h:214:82: note: expanded from macro 'SCLogErr' char _sc_log_err_msg[SC_LOG_MAX_LOG_MSG_LEN] = ""; \ ^~ 2 warnings generated. --- diff --git a/src/util-host-os-info.c b/src/util-host-os-info.c index 1eeaa531ac..6c2b38e6cb 100644 --- a/src/util-host-os-info.c +++ b/src/util-host-os-info.c @@ -176,6 +176,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) /* if we are here, we have an IPV4 address */ if ( (ipv4_addr = ValidateIPV4Address(ip_str)) == NULL) { SCLogError(SC_ERR_INVALID_IPV4_ADDR, "Invalid IPV4 address"); + SCFree(ip_str); return -1; } @@ -187,6 +188,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) if (netmask_value < 0 || netmask_value > 32) { SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV4 Netblock"); SCFree(ipv4_addr); + SCFree(ip_str); return -1; } @@ -198,6 +200,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) /* if we are here, we have an IPV6 address */ if ( (ipv6_addr = ValidateIPV6Address(ip_str)) == NULL) { SCLogError(SC_ERR_INVALID_IPV6_ADDR, "Invalid IPV6 address inside"); + SCFree(ip_str); return -1; } @@ -209,6 +212,7 @@ int SCHInfoAddHostOSInfo(char *host_os, char *host_os_ip_range, int is_ipv4) if (netmask_value < 0 || netmask_value > 128) { SCLogError(SC_ERR_INVALID_IP_NETBLOCK, "Invalid IPV6 Netblock"); SCFree(ipv6_addr); + SCFree(ip_str); return -1; }