From 178ba31982a228c8325644f4b200790d1e9fdb5a Mon Sep 17 00:00:00 2001 From: sunil Date: Fri, 9 Oct 2015 16:47:14 +0000 Subject: [PATCH] Convert fgetln(3) to getline(3). Ok eric@ todd@ gilles@ --- usr.sbin/smtpd/mta_session.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index 4ad29d2bf4a..70d863448e3 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.72 2015/10/02 00:44:30 gilles Exp $ */ +/* $OpenBSD: mta_session.c,v 1.73 2015/10/09 16:47:14 sunil Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -1364,13 +1364,14 @@ mta_send(struct mta_session *s, char *fmt, ...) static ssize_t mta_queue_data(struct mta_session *s) { - char *ln; - size_t len, q; + char *ln = NULL; + size_t sz = 0, q; + ssize_t len; q = iobuf_queued(&s->iobuf); while (iobuf_queued(&s->iobuf) < MTA_HIWAT) { - if ((ln = fgetln(s->datafp, &len)) == NULL) + if ((len = getline(&ln, &sz, s->datafp)) == -1) break; if (ln[len - 1] == '\n') ln[len - 1] = '\0'; @@ -1378,6 +1379,7 @@ mta_queue_data(struct mta_session *s) *ln == '.' ? "." : "", ln); } + free(ln); if (ferror(s->datafp)) { mta_flush_task(s, IMSG_MTA_DELIVERY_TEMPFAIL, "Error reading content file", 0, 0); -- 2.20.1