From d0b63ae8923bfe294ef8c34920ad630b06bfd142 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 4 Apr 2012 14:13:50 +0000 Subject: [PATCH] [package] quagga: add upstream patches fixing memory leaks Signed-off-by: Oliver Smith git-svn-id: svn://svn.openwrt.org/openwrt/packages@31190 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/quagga/Makefile | 2 +- .../patches/180-fix-lib-connect-memleak.patch | 61 ++++++++++++++++++++++ net/quagga/patches/181-ospf-null-ptr-fix.patch | 51 ++++++++++++++++++ net/quagga/patches/182-fix-bgpd-memleak.patch | 20 +++++++ 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 net/quagga/patches/180-fix-lib-connect-memleak.patch create mode 100644 net/quagga/patches/181-ospf-null-ptr-fix.patch create mode 100644 net/quagga/patches/182-fix-bgpd-memleak.patch diff --git a/net/quagga/Makefile b/net/quagga/Makefile index 3f5255a55..94d2c544c 100644 --- a/net/quagga/Makefile +++ b/net/quagga/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=quagga PKG_VERSION:=0.99.20 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_MD5SUM:=64cc29394eb8a4e24649d19dac868f64 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz diff --git a/net/quagga/patches/180-fix-lib-connect-memleak.patch b/net/quagga/patches/180-fix-lib-connect-memleak.patch new file mode 100644 index 000000000..85b6c1085 --- /dev/null +++ b/net/quagga/patches/180-fix-lib-connect-memleak.patch @@ -0,0 +1,61 @@ +From b24b19f719fdd9c3d61a0c93552cd64d832d964c Mon Sep 17 00:00:00 2001 +From: Stephen Hemminger +Date: Tue, 6 Dec 2011 14:09:18 +0400 +Subject: [PATCH] lib: fix memory leak on connect() failure + +Change sockunion_log() to not use strdup(). This fixes a small memory +leak that occurs on every failed connect(), and is simpler/cleaner. +--- + lib/sockunion.c | 23 +++++++++++------------ + 1 files changed, 11 insertions(+), 12 deletions(-) + +--- a/lib/sockunion.c ++++ b/lib/sockunion.c +@@ -297,27 +297,24 @@ sockunion_sizeof (union sockunion *su) + } + + /* return sockunion structure : this function should be revised. */ +-static char * +-sockunion_log (union sockunion *su) ++static const char * ++sockunion_log (union sockunion *su, char *buf, size_t len) + { +- static char buf[SU_ADDRSTRLEN]; +- + switch (su->sa.sa_family) + { + case AF_INET: +- snprintf (buf, SU_ADDRSTRLEN, "%s", inet_ntoa (su->sin.sin_addr)); +- break; ++ return inet_ntop(AF_INET, &su->sin.sin_addr, buf, len); ++ + #ifdef HAVE_IPV6 + case AF_INET6: +- snprintf (buf, SU_ADDRSTRLEN, "%s", +- inet_ntop (AF_INET6, &(su->sin6.sin6_addr), buf, SU_ADDRSTRLEN)); ++ return inet_ntop(AF_INET6, &(su->sin6.sin6_addr), buf, len); + break; + #endif /* HAVE_IPV6 */ ++ + default: +- snprintf (buf, SU_ADDRSTRLEN, "af_unknown %d ", su->sa.sa_family); +- break; ++ snprintf (buf, len, "af_unknown %d ", su->sa.sa_family); ++ return buf; + } +- return (XSTRDUP (MTYPE_TMP, buf)); + } + + /* sockunion_connect returns +@@ -379,8 +376,10 @@ sockunion_connect (int fd, union sockuni + { + if (errno != EINPROGRESS) + { ++ char str[SU_ADDRSTRLEN]; + zlog_info ("can't connect to %s fd %d : %s", +- sockunion_log (&su), fd, safe_strerror (errno)); ++ sockunion_log (&su, str, sizeof str), ++ fd, safe_strerror (errno)); + return connect_error; + } + } diff --git a/net/quagga/patches/181-ospf-null-ptr-fix.patch b/net/quagga/patches/181-ospf-null-ptr-fix.patch new file mode 100644 index 000000000..9ae47cff1 --- /dev/null +++ b/net/quagga/patches/181-ospf-null-ptr-fix.patch @@ -0,0 +1,51 @@ +From 6a2e0f36b103386e57dbe3a6ee4716e809111198 Mon Sep 17 00:00:00 2001 +From: Stephen Hemminger +Date: Tue, 6 Dec 2011 14:04:12 +0400 +Subject: [PATCH] lib: call filter delete hook before freeing access list + +The delete_hook was being run after calling access list delete function. +This would cause ospf to dereference a NULL, in ospf_filter_update +because 'access->name' was already freed. + +See also: + https://bugzilla.vyatta.com/show_bug.cgi?id=7654 +--- + lib/filter.c | 12 ++++++------ + 1 files changed, 6 insertions(+), 6 deletions(-) + +--- a/lib/filter.c ++++ b/lib/filter.c +@@ -1337,13 +1337,13 @@ DEFUN (no_access_list_all, + + master = access->master; + +- /* Delete all filter from access-list. */ +- access_list_delete (access); +- + /* Run hook function. */ + if (master->delete_hook) + (*master->delete_hook) (access); + ++ /* Delete all filter from access-list. */ ++ access_list_delete (access); ++ + return CMD_SUCCESS; + } + +@@ -1508,13 +1508,13 @@ DEFUN (no_ipv6_access_list_all, + + master = access->master; + +- /* Delete all filter from access-list. */ +- access_list_delete (access); +- + /* Run hook function. */ + if (master->delete_hook) + (*master->delete_hook) (access); + ++ /* Delete all filter from access-list. */ ++ access_list_delete (access); ++ + return CMD_SUCCESS; + } + diff --git a/net/quagga/patches/182-fix-bgpd-memleak.patch b/net/quagga/patches/182-fix-bgpd-memleak.patch new file mode 100644 index 000000000..308458512 --- /dev/null +++ b/net/quagga/patches/182-fix-bgpd-memleak.patch @@ -0,0 +1,20 @@ +From ce0af6ff5a4f200035ed4134da72a67f49a21dd6 Mon Sep 17 00:00:00 2001 +From: "Oleg A. Arkhangelsky" +Date: Sat, 3 Dec 2011 15:18:19 +0400 +Subject: [PATCH] bgpd: fix memory leak for extra attributes + +this fixes commit b881c7074bb698aeb1b099175b325734fc6e44d2 +--- + bgpd/bgp_attr.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +--- a/bgpd/bgp_attr.c ++++ b/bgpd/bgp_attr.c +@@ -675,6 +675,7 @@ bgp_attr_unintern (struct attr **attr) + } + + bgp_attr_unintern_sub (&tmp); ++ bgp_attr_extra_free (&tmp); + } + + void -- 2.11.0