diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2014-10-15 07:35:10 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2014-10-15 07:35:10 +0000 |
commit | 37c03430de7150b37b88580a8a15b9123f31be20 (patch) | |
tree | aef5b6e6a01737461f2f7afcf42baf36e30351f8 /usr.sbin/smtpd | |
parent | 4350d70da7a2dc4d69cf80c6e367b0d117bf94b6 (diff) |
fix memory leak in error path
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/rfc822.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/rfc822.c b/usr.sbin/smtpd/rfc822.c index 1e0ca34f352..0eec9a3c28f 100644 --- a/usr.sbin/smtpd/rfc822.c +++ b/usr.sbin/smtpd/rfc822.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rfc822.c,v 1.2 2014/10/12 18:58:57 gilles Exp $ */ +/* $OpenBSD: rfc822.c,v 1.3 2014/10/15 07:35:09 gilles Exp $ */ /* * Copyright (c) 2014 Gilles Chehade <gilles@poolp.org> @@ -57,10 +57,14 @@ parse_addresses(struct rfc822_parser *rp, const char *buffer, size_t len) if (*s == '"' && !rp->escape && !rp->comment) rp->quote = !rp->quote; if (!rp->comment && !rp->quote && !rp->escape) { - if (*s == '<' && rp->bracket) + if (*s == '<' && rp->bracket) { + free(ra); return 0; - if (*s == '>' && !rp->bracket) + } + if (*s == '>' && !rp->bracket) { + free(ra); return 0; + } if (*s == '<') { wptr = ra->address; @@ -84,12 +88,16 @@ parse_addresses(struct rfc822_parser *rp, const char *buffer, size_t len) } /* some flags still set, malformed header */ - if (rp->escape || rp->comment || rp->quote || rp->bracket) + if (rp->escape || rp->comment || rp->quote || rp->bracket) { + free(ra); return 0; + } /* no value, malformed header */ - if (ra->name[0] == '\0' && ra->address[0] == '\0') + if (ra->name[0] == '\0' && ra->address[0] == '\0') { + free(ra); return 0; + } /* no <>, use name as address */ if (ra->address[0] == '\0') { |