summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJorge Boncompte [DTI2] <jorge@dti2.net>2012-04-10 16:57:24 +0200
committerDavid Lamparter <equinox@diac24.net>2012-05-02 17:03:27 +0200
commitc63b83fe8d1addecc949258479b8d54180c4da60 (patch)
treefbc58da3014db1cf74a2f8a91a33fe941968815d /lib
parentd227617a972bb20a974be68bea5032e692a0970f (diff)
bgpd: Fix memory leak of some "show ip bgp neighbor" commands
sockunion_str2su() use is prone to memory leaks. Remove it's use all over the code. At least these commands leaked a sockunion union: - show ip bgp vpnv4 ... routes - show ip bgp ... received prefix-filter Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/sockunion.c33
-rw-r--r--lib/sockunion.h1
2 files changed, 0 insertions, 34 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c
index cfb6f9c5..4c2837b1 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -174,39 +174,6 @@ sockunion2str (union sockunion *su, char *buf, size_t len)
return NULL;
}
-union sockunion *
-sockunion_str2su (const char *str)
-{
- int ret;
- union sockunion *su;
-
- su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion));
-
- ret = inet_pton (AF_INET, str, &su->sin.sin_addr);
- if (ret > 0) /* Valid IPv4 address format. */
- {
- su->sin.sin_family = AF_INET;
-#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
- su->sin.sin_len = sizeof(struct sockaddr_in);
-#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
- return su;
- }
-#ifdef HAVE_IPV6
- ret = inet_pton (AF_INET6, str, &su->sin6.sin6_addr);
- if (ret > 0) /* Valid IPv6 address format. */
- {
- su->sin6.sin6_family = AF_INET6;
-#ifdef SIN6_LEN
- su->sin6.sin6_len = sizeof(struct sockaddr_in6);
-#endif /* SIN6_LEN */
- return su;
- }
-#endif /* HAVE_IPV6 */
-
- XFREE (MTYPE_SOCKUNION, su);
- return NULL;
-}
-
/* Convert IPv4 compatible IPv6 address to IPv4 address. */
static void
sockunion_normalise_mapped (union sockunion *su)
diff --git a/lib/sockunion.h b/lib/sockunion.h
index 8b060586..180b2b4d 100644
--- a/lib/sockunion.h
+++ b/lib/sockunion.h
@@ -94,7 +94,6 @@ extern const char *sockunion2str (union sockunion *, char *, size_t);
extern int sockunion_cmp (union sockunion *, union sockunion *);
extern int sockunion_same (union sockunion *, union sockunion *);
-extern union sockunion *sockunion_str2su (const char *str);
extern struct in_addr sockunion_get_in_addr (union sockunion *su);
extern int sockunion_accept (int sock, union sockunion *);
extern int sockunion_stream_socket (union sockunion *);