summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsunil <sunil@openbsd.org>2015-10-09 16:47:14 +0000
committersunil <sunil@openbsd.org>2015-10-09 16:47:14 +0000
commit178ba31982a228c8325644f4b200790d1e9fdb5a (patch)
tree56e841c6969d774659785f66f674e76ff077d598
parentA fork(2) is used in ttymsg() to delay the message to a tty if it (diff)
downloadwireguard-openbsd-178ba31982a228c8325644f4b200790d1e9fdb5a.tar.xz
wireguard-openbsd-178ba31982a228c8325644f4b200790d1e9fdb5a.zip
Convert fgetln(3) to getline(3).
Ok eric@ todd@ gilles@
-rw-r--r--usr.sbin/smtpd/mta_session.c10
1 files 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 <pyr@openbsd.org>
@@ -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);