fixed leak in udp transport Resolves: #247771

This commit is contained in:
Jan Šafránek 2007-07-31 08:23:19 +00:00
parent 9e790cb3ea
commit 9ed8c7e353
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,46 @@
--- snmplib/snmpUDPDomain.c 2006/09/19 23:42:17 15274
+++ snmplib/snmpUDPDomain.c 2006/12/28 23:29:44 15683
@@ -586,28 +586,24 @@
int rc = 0;
char *str = NULL;
char *client_socket = NULL;
- netsnmp_udp_addr_pair *addr_pair = NULL;
+ netsnmp_udp_addr_pair addr_pair;
if (addr == NULL || addr->sin_family != AF_INET) {
return NULL;
}
- addr_pair = (netsnmp_udp_addr_pair *) malloc(sizeof(netsnmp_udp_addr_pair));
- if (addr_pair == NULL) {
- return NULL;
- }
- memset(addr_pair, 0, sizeof(netsnmp_udp_addr_pair));
- memcpy(&(addr_pair->remote_addr), addr, sizeof(struct sockaddr_in));
+ memset(&addr_pair, 0, sizeof(netsnmp_udp_addr_pair));
+ memcpy(&(addr_pair.remote_addr), addr, sizeof(struct sockaddr_in));
t = (netsnmp_transport *) malloc(sizeof(netsnmp_transport));
if (t == NULL) {
return NULL;
}
- str = netsnmp_udp_fmtaddr(NULL, (void *)addr_pair,
+ str = netsnmp_udp_fmtaddr(NULL, (void *)&addr_pair,
sizeof(netsnmp_udp_addr_pair));
- DEBUGMSGTL(("netsnmp_udp", "open %s %s:%d\n", local ? "local" : "remote",
- str,addr->sin_port));
+ DEBUGMSGTL(("netsnmp_udp", "open %s %s\n", local ? "local" : "remote",
+ str));
free(str);
memset(t, 0, sizeof(netsnmp_transport));
@@ -690,7 +686,7 @@
t->remote[4] = (htons(addr->sin_port) & 0xff00) >> 8;
t->remote[5] = (htons(addr->sin_port) & 0x00ff) >> 0;
t->remote_length = 6;
- memcpy(t->data, addr_pair, sizeof(netsnmp_udp_addr_pair));
+ memcpy(t->data, &addr_pair, sizeof(netsnmp_udp_addr_pair));
t->data_length = sizeof(netsnmp_udp_addr_pair);
}

View File

@ -45,6 +45,7 @@ Patch19: net-snmp-5.3.1-shared-ip.patch
Patch20: net-snmp-5.3.1-mib-option.patch
Patch21: net-snmp-5.4-exec-crash.patch
Patch22: net-snmp-5.1.2-snmpconf-selinux.patch
Patch23: net-snmp-5.4-transport-leak.patch
Requires(pre): /sbin/chkconfig
Requires(post): /sbin/chkconfig
@ -168,6 +169,7 @@ and applications.
%patch20 -p1 -b .mib-option
%patch21 -p1 -b .exec-crash
%patch22 -p1 -b .selinux
%patch23 -p0 -b .transport-leak
# Do this patch with a perl hack...
perl -pi -e "s|'\\\$install_libdir'|'%{_libdir}'|" ltmain.sh
@ -375,9 +377,9 @@ rm -rf ${RPM_BUILD_ROOT}
%changelog
* Mon Jul 30 2007 Safranek <jsafranek@redhat.com> 5.4-16
- lm_sensors now supported on ppc64 (#249255)
- snmpconf generates config files with proper selinux context
(#247462)
- fixed leak in udp transport (#247771)
* Thu Jun 28 2007 Jan Safranek <jsafranek@redhat.com> 5.4-15
- fix default snmptrapd.conf