diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-30 20:59:44 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-30 20:59:44 +0000 |
commit | 503a8c85bf9b1b8f59ca6cf77745900bead089c9 (patch) | |
tree | ef09024a0e2d2b515d9976e34bd6e0c509325c74 /usr.sbin | |
parent | 734763169e94ae457cd653755000ed4aa04b5a42 (diff) |
missing free()s in error cases that (now) lead to program termination
From: Patrick Latifi <pat@eyeo.org>
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/imsg.c | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 95e3c0ba3f0..a046d330d3a 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.45 2003/12/27 14:58:22 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.46 2003/12/30 20:59:43 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -358,10 +358,14 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_config *conf) wbuf = buf_open(len); if (wbuf == NULL) return (-1); - if (buf_add(wbuf, imsg.data, len) == -1) + if (buf_add(wbuf, imsg.data, len) == -1) { + free(wbuf); return (-1); - if ((n = buf_close(&m->msgbuf, wbuf)) < 0) + } + if ((n = buf_close(&m->msgbuf, wbuf)) < 0) { + free(wbuf); return (-1); + } break; } break; diff --git a/usr.sbin/bgpd/imsg.c b/usr.sbin/bgpd/imsg.c index fb92c6d6003..2214fb7e2d1 100644 --- a/usr.sbin/bgpd/imsg.c +++ b/usr.sbin/bgpd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.12 2003/12/28 14:34:30 henning Exp $ */ +/* $OpenBSD: imsg.c,v 1.13 2003/12/30 20:59:43 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -101,16 +101,19 @@ imsg_compose(struct imsgbuf *ibuf, int type, u_int32_t peerid, void *data, } if (buf_add(wbuf, &hdr, sizeof(hdr)) == -1) { logit(LOG_CRIT, "imsg_compose: buf_add error"); + free(wbuf); return (-1); } if (datalen) if (buf_add(wbuf, data, datalen) == -1) { logit(LOG_CRIT, "imsg_compose: buf_add error"); + free(wbuf); return (-1); } if ((n = buf_close(&ibuf->w, wbuf)) < 0) { logit(LOG_CRIT, "imsg_compose: buf_add error"); + free(wbuf); return (-1); } return (n); |