From nobody Fri Nov 18 20:59:48 2022 X-Original-To: dev-commits-src-all@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 4NDTgT0Ky1z4hH8K; Fri, 18 Nov 2022 20:59:49 +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 4NDTgS70n0z3qVD; Fri, 18 Nov 2022 20:59:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668805189; 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=1dYEbUiDoI26N6BLkpMvFdBnVOVdvB7Klgow9IuK5rk=; b=A7Os2hSbaNHLMkgETpV1hrOzo27PbUgOHieoL0xTiLBaEQ8ZoMVTRW08fyL9gpzCjK85JS qMXJzxw+09D+IfUyc8+KcYcj0nwdfUlC2QzDrRc4avRx9CMTFVfGh4hEh8uI/OvL0AOPw+ S6dCz6GHyC1cDYGfGOKkr2c8q+09eTMSpdRKFe6/dYOjr3oi9vRVy2MstmM2YviUpswFsE fxZzn47DC0bv9nX2RX7BlxNNdTYCYWCAy1lqIy7wMvWzIA+bNRc35u5rd6MOrhX25qsNoM 1l4s309cirk5n542XrXEiznPd/Wk6izzQhkZZAGSMiu7LcEKgv2WtiGq/6nGIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668805189; 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=1dYEbUiDoI26N6BLkpMvFdBnVOVdvB7Klgow9IuK5rk=; b=PJeUtjBMJiISW5CJHztDEwgNHtssM63yjn37ooVQNWfDkuLQuDSsmzcOISx8GbeHv2VQZ5 TXoOjRPfiAQaccCTqlXWUuHYovpi7Vh3x5oZd15v6eVF2kuRQ5orF2WUGGbydAjYdbPs4w lgpBb5J0s9WgCRa+IdhXIYoWQWwjvKImY7bMsFrsn92T4X4gQiM+DdhgZV1mmhfq8TXJ4J CDEdctHoGoH15VD/1bGw0rG7JD+URr0Asvtjqkdfa7I0CD9JYhcVpYTQPLZ0X7nx0HU2cb eDECVMKPkW4mUurYK5ttBf0Ig9y/z7m0aRNw2H0Db6ERluj4UXCUWUq0xtWjkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668805189; a=rsa-sha256; cv=none; b=UDdbNCoohng692v5aMsBh6Igmg329JaANzBTdufW9WV+waDE0IoU2Q24haNHbizinrSHhl PhRUzK7+VABQvTt25UnVBUpw97O3FNpqGkzx7YNTCAyvhKper236Ea0BMg4H6wtkivh3eh hgTVBkWMbVzSU/4l7ylTxBjMkPthAQGdmSSBV+nXVoSXtZiVEab/qPY5e8Aapqfd9ri2v0 4u3NqX6H0FGm+QRN0Ze8Ll9pncwJ8H9lj2iBzzm6BNqjEZRKaEP97hqjmvOgNBGYPEQcpJ Y44N5zZt4KnF9MKkynK+Dm41D1lWYCD1Dmy3c6x6gkEpkzREJj4R8lPcFBXOdQ== 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 4NDTgS64dNzL6Q; Fri, 18 Nov 2022 20:59:48 +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 2AIKxmaT043456; Fri, 18 Nov 2022 20:59:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AIKxmHd043455; Fri, 18 Nov 2022 20:59:48 GMT (envelope-from git) Date: Fri, 18 Nov 2022 20:59:48 GMT Message-Id: <202211182059.2AIKxmHd043455@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 166551aa4da5 - stable/12 - dma: use canonical getline() loop List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/12 X-Git-Reftype: branch X-Git-Commit: 166551aa4da5705fa7d58c7aaefbcc472e5cdd03 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=166551aa4da5705fa7d58c7aaefbcc472e5cdd03 commit 166551aa4da5705fa7d58c7aaefbcc472e5cdd03 Author: Ed Maste AuthorDate: 2022-02-03 18:51:06 +0000 Commit: Ed Maste CommitDate: 2022-11-18 20:57:45 +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 (cherry picked from commit d21e71efce3963b068ccaa807a099b591dc220e9) (cherry picked from commit 2e8403e0215868a13e2bdd1c979fc351971b8d91) --- 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);