-/* $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>
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';
*ln == '.' ? "." : "", ln);
}
+ free(ln);
if (ferror(s->datafp)) {
mta_flush_task(s, IMSG_MTA_DELIVERY_TEMPFAIL,
"Error reading content file", 0, 0);