summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/parse.y
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-06-08 14:34:49 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-06-08 14:34:49 +0000
commit47d1e1def7241b452d5da2a59f07a846818ea6b8 (patch)
tree411255a7639adb3ccd599ecdff042063205b1dc8 /usr.sbin/bgpd/parse.y
parent38cb2693a6ed3f2e05942c521294450aa3845245 (diff)
fix a few memory leaks in error paths and one in the pftable path,
and simplyfy the prefix production error handling slightly from Mr. Memleak Terminator Patrick Latifi <pat@eyeo.org>, kickass!
Diffstat (limited to 'usr.sbin/bgpd/parse.y')
-rw-r--r--usr.sbin/bgpd/parse.y18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y
index 846b0bb6ff1..9ae7f6bfe55 100644
--- a/usr.sbin/bgpd/parse.y
+++ b/usr.sbin/bgpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.113 2004/06/06 17:38:10 henning Exp $ */
+/* $OpenBSD: parse.y,v 1.114 2004/06/08 14:34:48 henning Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -360,15 +360,13 @@ prefix : STRING '/' number {
if (asprintf(&s, "%s/%u", $1, $3) == -1)
fatal(NULL);
+ free($1);
if (!host(s, &$$.prefix, &$$.len)) {
- yyerror("could not parse address \"%s/%u\"",
- $1, $3);
+ yyerror("could not parse address \"%s\"", s);
free(s);
- free($1);
YYERROR;
}
- free($1);
free(s);
}
;
@@ -528,6 +526,7 @@ peeropts : REMOTEAS asnumber {
| TCP MD5SIG PASSWORD string {
if (curpeer->conf.auth.method) {
yyerror("auth method cannot be redefined");
+ free($4);
YYERROR;
}
if (strlcpy(curpeer->conf.auth.md5key, $4,
@@ -545,6 +544,7 @@ peeropts : REMOTEAS asnumber {
| TCP MD5SIG KEY string {
if (curpeer->conf.auth.method) {
yyerror("auth method cannot be redefined");
+ free($4);
YYERROR;
}
@@ -579,6 +579,8 @@ peeropts : REMOTEAS asnumber {
($2 == 0 && curpeer->conf.auth.method !=
AUTH_IPSEC_MANUAL_AH))) {
yyerror("auth method cannot be redefined");
+ free($6);
+ free($7);
YYERROR;
}
@@ -590,8 +592,8 @@ peeropts : REMOTEAS asnumber {
keylen = 16;
} else {
yyerror("unknown auth algorithm \"%s\"", $6);
- free($7);
free($6);
+ free($7);
YYERROR;
}
free($6);
@@ -935,17 +937,21 @@ filter_set_opt : LOCALPREF number {
$$.flags = SET_PFTABLE;
if (pftable_exists($2) != 0) {
yyerror("pftable name does not exist");
+ free($2);
YYERROR;
}
if (strlcpy($$.pftable, $2, sizeof($$.pftable)) >=
sizeof($$.pftable)) {
yyerror("pftable name too long");
+ free($2);
YYERROR;
}
if (pftable_add($2) != 0) {
yyerror("Couldn't register table");
+ free($2);
YYERROR;
}
+ free($2);
}
| COMMUNITY STRING {
$$.flags = SET_COMMUNITY;