diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2015-10-07 19:25:43 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2015-10-07 19:25:43 +0000 |
commit | 3d8e62749923b01053ebbbb7a469736de03b3dae (patch) | |
tree | 20938cfc5899af7bc14028b53dd3eab7c0f1cb66 | |
parent | fa923e0708220d89105b47a45327376940f45364 (diff) |
Use getline(3) rather than fgetln(3). OK gilles@
-rw-r--r-- | usr.sbin/smtpd/bounce.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index ac6f84fef20..3abdf2a3a92 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.66 2015/01/20 17:37:54 deraadt Exp $ */ +/* $OpenBSD: bounce.c,v 1.67 2015/10/07 19:25:42 millert Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@poolp.org> @@ -384,8 +384,9 @@ static int bounce_next(struct bounce_session *s) { struct bounce_envelope *evp; - char *line; - size_t len, n; + char *line = NULL; + size_t n, sz = 0; + ssize_t len; switch (s->state) { case BOUNCE_EHLO: @@ -480,12 +481,12 @@ bounce_next(struct bounce_session *s) n = iobuf_queued(&s->iobuf); while (iobuf_queued(&s->iobuf) < BOUNCE_HIWAT) { - line = fgetln(s->msgfp, &len); - if (line == NULL) + if ((len = getline(&line, &sz, s->msgfp)) == -1) break; if (len == 1 && line[0] == '\n' && /* end of headers */ s->msg->bounce.type == B_DSN && s->msg->bounce.dsn_ret == DSN_RETHDRS) { + free(line); fclose(s->msgfp); s->msgfp = NULL; bounce_send(s, "."); @@ -497,6 +498,7 @@ bounce_next(struct bounce_session *s) "bounce_next: DATA_MESSAGE", "%s%s\n", (len == 2 && line[0] == '.') ? "." : "", line); } + free(line); if (ferror(s->msgfp)) { fclose(s->msgfp); |