diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-09-16 15:20:51 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2007-09-16 15:20:51 +0000 |
commit | f84625947c74468d1b3829f9e49a5c8d72d5444f (patch) | |
tree | e5ff9dd7593923df6234b6c5c09d6d9b8685c024 | |
parent | e53c2f9d614786535dfcb813ee64f4cebe0c2c96 (diff) |
log_fmt_peer() does not use a static buffer so it is necessary to free the
string that it returned later. rde_update_log() did not do that.
Memory leak found and diff provided by Mike Belopuhov.
-rw-r--r-- | usr.sbin/bgpd/rde.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 6c46102eecd..5f1ed2fb42a 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.227 2007/06/19 09:44:55 pyr Exp $ */ +/* $OpenBSD: rde.c,v 1.228 2007/09/16 15:20:50 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1542,6 +1542,7 @@ rde_update_log(const char *message, const struct rde_peer *peer, const struct bgpd_addr *next, const struct bgpd_addr *prefix, u_int8_t prefixlen) { + char *l = NULL; char *n = NULL; char *p = NULL; @@ -1553,10 +1554,12 @@ rde_update_log(const char *message, n = NULL; if (asprintf(&p, "%s/%u", log_addr(prefix), prefixlen) == -1) p = NULL; + l = log_fmt_peer(&peer->conf); log_info("%s AS%s: %s %s%s", - log_fmt_peer(&peer->conf), log_as(peer->conf.remote_as), message, + l, log_as(peer->conf.remote_as), message, p ? p : "out of memory", n ? n : ""); + free(l); free(n); free(p); } |