From nobody Sun Feb 06 02:55:49 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 25EE619B5BDC; Sun, 6 Feb 2022 02:55:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jrv6G0c1sz4tXM; Sun, 6 Feb 2022 02:55:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644116150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=quLqoQsmXyB0xPD/Vhxin01lDLHkXE0dhBTsFtZNcNo=; b=kghvtEzox/Td3vryXDg1HoSLNHoEFWJm56ATGhE6JGTMV6lZu59Ds5VbWC2wPHvfWoEVTm j6HmiXAYPYDL/FFUsjwmkBcAEfP4PEU5MXjrLmOusUXPOU7+rkhXz5e2CF8+UiQCxb5eV9 Y1T+uRlzR1FFSeHZum7CFJ/Jaa4Mx1cejlmDhQgKMB1OzHyTJSNlj26eDtJPkqx0i/Y/Wl mwdGOFZYos88V2HUUMD5CKsOlqwEMaE9SaqXDjgXVLaJbBdAEwVV9wIHR1B0uCITmwW9YO t34hQZgWu+x93x4TnHXQjaAM+SK/pPE2689gVo4UDSpuLDctglbsa2QFkfbFKg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E4B5927E2; Sun, 6 Feb 2022 02:55:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2162tnkq081325; Sun, 6 Feb 2022 02:55:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2162tnJL081324; Sun, 6 Feb 2022 02:55:49 GMT (envelope-from git) Date: Sun, 6 Feb 2022 02:55:49 GMT Message-Id: <202202060255.2162tnJL081324@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: d21e71efce39 - main - dma: use canonical getline() loop List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d21e71efce3963b068ccaa807a099b591dc220e9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644116150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=quLqoQsmXyB0xPD/Vhxin01lDLHkXE0dhBTsFtZNcNo=; b=mxH/rW5GcSNy4UqsnqOM/q9Wpb9NhKRKln0mkQXskmiF7RuyIjqf1lvi2lj0D5ElKW6SUi Jb+gFEOnD7dZwCrOhJrKlfywe8CvVGIqShYnnSZ3VLJRAiWGoR1TXvEAoBVHsDZV5hB9gj bc9xBxxlFubAHcjc1GEe3cs7bBIr3Er4w/OWZJvxSGEITTaKAJfjKS0lNzOqjzStcwvUxo rJt1E8kRKjfU+6hu9TcAmOWwQaR/s+VCL7m6WRTQGOANKMBsIQ1neWZ0VUDeeef3NJb5ja YYQ36UoKHxerN+9WR9qO+pTIrdUuIJHE1BbdNIyqKehMuLnX+m/GJD4VcEh6fQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644116150; a=rsa-sha256; cv=none; b=oFX4D66EdLf6OkI9KiUYEpnIx/Pd6L/Doc9U3qT17OqtKymQekUhlywaDbc6ls7V6WnhGk ij1RkXIsITEIU9k/IG0x6PLHcRKGAVd68BS2NNM0ma64DpI8l0IAYUWp3TtqdQ41QWNkTo JLF3yHAgL56BSG9XyUvGmC4zdMbKh/mL/U7XsqbzbQ/RfbUlA3uqLgOEvH/ByL5JdETswi UKkxT3NGuevavdIEDvPNUDR4bhu3B70gtDA3w2yXxRsf7wDhGbQyySOfkB5dgrQnlMaRVe Vx14AUwzkRC7jrwC35Y4Kmrq3mvn2nT9iWxOcvaLX+nqTUhXPWzoR6JQJDXipw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d21e71efce3963b068ccaa807a099b591dc220e9 commit d21e71efce3963b068ccaa807a099b591dc220e9 Author: Ed Maste AuthorDate: 2022-02-03 18:51:06 +0000 Commit: Ed Maste CommitDate: 2022-02-06 02:55:03 +0000 dma: use canonical getline() loop getline() returns -1 on erorr or EOF, so use that condition instead of feof() and check that there was no error after the loop exits. Reviewed by: bapt, kevans (both earlier) MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34159 --- contrib/dma/mail.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/contrib/dma/mail.c b/contrib/dma/mail.c index 9e00c22d71db..9641818b8814 100644 --- a/contrib/dma/mail.c +++ b/contrib/dma/mail.c @@ -405,10 +405,8 @@ readmail(struct queue *queue, int nodot, int recp_from_header) if ((ssize_t)error < 0) return (-1); - while (!feof(stdin)) { + while ((linelen = getline(&line, &linecap, stdin)) > 0) { newline[0] = '\0'; - if ((linelen = getline(&line, &linecap, stdin)) <= 0) - break; if (had_last_line) errlogx(EX_DATAERR, "bad mail input format:" " from %s (uid %d) (envelope-from %s)", @@ -510,8 +508,8 @@ readmail(struct queue *queue, int nodot, int recp_from_header) } } } - - ret = 0; + if (ferror(stdin) == 0) + ret = 0; fail: free(line); return (ret);