summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog13
-rw-r--r--bgpd/bgp_filter.c44
-rw-r--r--bgpd/bgp_route.c3
-rw-r--r--bgpd/bgp_routemap.c2
-rw-r--r--bgpd/bgp_vty.c17
5 files changed, 25 insertions, 54 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 93dc8c3b..6bee4def 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,16 @@
+2005-01-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * bgp_filter.c: (ip_as_path,no_ip_as_path) Use argv_concat instead
+ of buffer_getstr.
+ * bgp_route.c: (bgp_show_regexp) Fix memory leak: need to free string
+ returned by buffer_getstr.
+ (bgp_show_community) Must use XFREE instead of free on string
+ returned by buffer_getstr.
+ * bgp_routemap.c: (set_community) Must use XFREE instead of free
+ on string returned by buffer_getstr.
+ * bgp_vty.c: (neighbor_description) Use argv_concat instead of
+ buffer_getstr.
+
2005-01-24 Hasso Tepper <hasso at quagga.net>
* bgp_route.c: Fix showstopper bug. New route must be selected also
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index 09dcc0fa..2f43cd05 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -446,10 +446,7 @@ DEFUN (ip_as_path, ip_as_path_cmd,
struct as_filter *asfilter;
struct as_list *aslist;
regex_t *regex;
- struct buffer *b;
- int i;
char *regstr;
- int first = 0;
/* Check the filter type. */
if (strncmp (argv[1], "p", 1) == 0)
@@ -463,25 +460,12 @@ DEFUN (ip_as_path, ip_as_path_cmd,
}
/* Check AS path regex. */
- b = buffer_new (1024);
- for (i = 2; i < argc; i++)
- {
- if (first)
- buffer_putc (b, ' ');
- else
- first = 1;
-
- buffer_putstr (b, argv[i]);
- }
- buffer_putc (b, '\0');
-
- regstr = buffer_getstr (b);
- buffer_free (b);
+ regstr = argv_concat(argv, argc, 2);
regex = bgp_regcomp (regstr);
if (!regex)
{
- free (regstr);
+ XFREE (MTYPE_TMP, regstr);
vty_out (vty, "can't compile regexp %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
@@ -489,7 +473,7 @@ DEFUN (ip_as_path, ip_as_path_cmd,
asfilter = as_filter_make (regex, regstr, type);
- free (regstr);
+ XFREE (MTYPE_TMP, regstr);
/* Install new filter to the access_list. */
aslist = as_list_get (argv[0]);
@@ -518,9 +502,6 @@ DEFUN (no_ip_as_path,
enum as_filter_type type;
struct as_filter *asfilter;
struct as_list *aslist;
- struct buffer *b;
- int i;
- int first = 0;
char *regstr;
regex_t *regex;
@@ -545,25 +526,12 @@ DEFUN (no_ip_as_path,
}
/* Compile AS path. */
- b = buffer_new (1024);
- for (i = 2; i < argc; i++)
- {
- if (first)
- buffer_putc (b, ' ');
- else
- first = 1;
-
- buffer_putstr (b, argv[i]);
- }
- buffer_putc (b, '\0');
-
- regstr = buffer_getstr (b);
- buffer_free (b);
+ regstr = argv_concat(argv, argc, 2);
regex = bgp_regcomp (regstr);
if (!regex)
{
- free (regstr);
+ XFREE (MTYPE_TMP, regstr);
vty_out (vty, "can't compile regexp %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
@@ -572,7 +540,7 @@ DEFUN (no_ip_as_path,
/* Lookup asfilter. */
asfilter = as_filter_lookup (aslist, regstr, type);
- free (regstr);
+ XFREE (MTYPE_TMP, regstr);
bgp_regex_free (regex);
if (asfilter == NULL)
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 849cc44f..40a61b61 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -6136,6 +6136,7 @@ bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
buffer_free (b);
regex = bgp_regcomp (regstr);
+ XFREE(MTYPE_TMP, regstr);
if (! regex)
{
vty_out (vty, "Can't compile regexp %s%s", argv[0],
@@ -6712,7 +6713,7 @@ bgp_show_community (struct vty *vty, int argc, const char **argv, int exact,
buffer_free (b);
com = community_str2com (str);
- free (str);
+ XFREE (MTYPE_TMP, str);
if (! com)
{
vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index e2ad5e0f..76740056 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -2846,7 +2846,7 @@ DEFUN (set_community,
if (str)
{
com = community_str2com (str);
- free (str);
+ XFREE (MTYPE_TMP, str);
}
/* Can't compile user input into communities attribute. */
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 027b8ca9..5968f68c 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -28,6 +28,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "stream.h"
#include "thread.h"
#include "log.h"
+#include "memory.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_attr.h"
@@ -2576,9 +2577,7 @@ DEFUN (neighbor_description,
"Up to 80 characters describing this neighbor\n")
{
struct peer *peer;
- struct buffer *b;
char *str;
- int i;
peer = peer_and_group_lookup_vty (vty, argv[0]);
if (! peer)
@@ -2587,21 +2586,11 @@ DEFUN (neighbor_description,
if (argc == 1)
return CMD_SUCCESS;
- /* Make string from buffer. This function should be provided by
- buffer.c. */
- b = buffer_new (1024);
- for (i = 1; i < argc; i++)
- {
- buffer_putstr (b, argv[i]);
- buffer_putc (b, ' ');
- }
- buffer_putc (b, '\0');
- str = buffer_getstr (b);
- buffer_free (b);
+ str = argv_concat(argv, argc, 1);
peer_description_set (peer, str);
- free (str);
+ XFREE (MTYPE_TMP, str);
return CMD_SUCCESS;
}