From nobody Thu May 29 20:08:56 2025 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 4b7crm4ncsz5xRlg; Thu, 29 May 2025 20:08:56 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4b7crm2pFSz3TG1; Thu, 29 May 2025 20:08:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748549336; 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=2qFtmUPo3D2/iCk1plRAnWYf53z3evx/WedGMbjVB8I=; b=yOcVWCIDEZQK3/9zAtlcGn9ZL39Rl/mzyNm3aFboJJqo+rRgwp+vKYC4K7uiqC/nRj0FKj L0fUidPgIrkJlXRPoCq6cc79L0uVZwDKJH1JP3TOyjMXXvxvracRxoaNuJPnMRXE/TasxV AE+X7Er8wPY7oZX5WrDdM0ZmI3WrjHTbd3I7jMu9hJ+mjA9CJgD9gVtFooJlAi77o4WTmt DNhvDLTJ/Mi9IOWB7211hOzivANd54sbZU7dTTUokoFxjbH+4XmycDVt4jAdPzg6CspM1Y rNMmM6UUEpGKgaFWQoaHsO0AnD3B9c0y/5uKVMC7P5T29K6izx89vRODJPo1LQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748549336; a=rsa-sha256; cv=none; b=NPuqo/s519tMX4k5yv0pm5KewK6A8rwxOg/FOHO8n8AEDkykr+m0dXqrp9FX3Q1t0jnivO ae2WxOUvNSwnAArLuiKdrKsTpZRMOhvCVavQPYTPzyCgLGu9cx+YAGH8pqqoXlVxqORfMB 8CdtIXGZlr0q9QLv0KPkO/ywjjzimCVjjmKQ2TKeBCahKXBu22Ui9kYFmn4aF8raoYkrca eFTChe5z90vjjeXZ5IH3XwcpA0eBsBlZI9+YAegWLj2U45TqqieJw6TGMBs79dpW1zyD/j 4rEQyaHBMBdZKq/aBJQNKWh/jAcKyTPW6igwHGsmS+l6yZMeQEUxca9wanBqPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748549336; 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=2qFtmUPo3D2/iCk1plRAnWYf53z3evx/WedGMbjVB8I=; b=KxET2teliuZUR8AhNDm8JyVADQHdJNeyrSKQJ6wgD9XSZP4QwPIKIzYXuaCGVUPZHbCSB+ z0z39ynylIyihRD7ww8NMm1hRL1Cf/IkWVkj4VPqcEiVH30Og12AGrt5oCocRLRvuXr2g3 RwF6BrOSWqwc+JjKO+SQJTGogP46XT7ABV2e7OgBX9lPWtsEDE6gVAjMOUWObMrSQTn1cb yOIsKnrS/PxrxbhuL8GFJDmT7Cp2WbsfRPoclnxj7Pk9cdNZy7VW8hz+Pj8rT7BZfKZooM ZzctbUBn6WDHgIC25zMD1OpqRwUacx+PVQObkeT7hes7HBVpb7cRUrHVzf4dHQ== 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 4b7crm2MMSz5np; Thu, 29 May 2025 20:08:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54TK8uw4051343; Thu, 29 May 2025 20:08:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54TK8u9T051340; Thu, 29 May 2025 20:08:56 GMT (envelope-from git) Date: Thu, 29 May 2025 20:08:56 GMT Message-Id: <202505292008.54TK8u9T051340@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 2e47009079fc - main - mail: don't rewrite buffer sizes as much 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e47009079fc01ca05c9779d85616e1df037693c Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=2e47009079fc01ca05c9779d85616e1df037693c commit 2e47009079fc01ca05c9779d85616e1df037693c Author: Kyle Evans AuthorDate: 2025-05-29 20:08:49 +0000 Commit: Kyle Evans CommitDate: 2025-05-29 20:08:49 +0000 mail: don't rewrite buffer sizes as much Thes buffers are arrays with a known size, just use sizeof() rather than rewriting their sizes -- no functional change, slightly more resilient against future possible errors. Reviewed by: markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50582 --- usr.bin/mail/collect.c | 11 ++++++----- usr.bin/mail/lex.c | 3 ++- usr.bin/mail/util.c | 10 +++++----- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c index 97c4d499ea3a..8c308d217195 100644 --- a/usr.bin/mail/collect.c +++ b/usr.bin/mail/collect.c @@ -152,7 +152,7 @@ cont: } for (;;) { colljmp_p = 1; - c = readline(stdin, linebuf, LINESIZE); + c = readline(stdin, linebuf, sizeof(linebuf)); colljmp_p = 0; if (c < 0) { if (value("interactive") != NULL && @@ -163,7 +163,7 @@ cont: break; } lastlong = longline; - longline = c == LINESIZE - 1; + longline = c == sizeof(linebuf) - 1; eofcount = 0; hadintr = 0; if (linebuf[0] == '.' && linebuf[1] == '\0' && @@ -384,11 +384,12 @@ cont: (void)fflush(stdout); lc = 0; cc = 0; - while ((rc = readline(fbuf, linebuf, LINESIZE)) >= 0) { - if (rc != LINESIZE - 1) + while ((rc = readline(fbuf, linebuf, + sizeof(linebuf))) >= 0) { + if (rc != sizeof(linebuf) - 1) lc++; if ((t = putline(collf, linebuf, - rc != LINESIZE - 1)) < 0) { + rc != sizeof(linebuf) - 1)) < 0) { (void)Fclose(fbuf); goto err; } diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index 2d86a17c13e9..1c39c876b3f1 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -223,7 +223,8 @@ commands(void) */ n = 0; for (;;) { - if (readline(input, &linebuf[n], LINESIZE - n) < 0) { + if (readline(input, &linebuf[n], + sizeof(linebuf) - n) < 0) { if (n == 0) n = -1; break; diff --git a/usr.bin/mail/util.c b/usr.bin/mail/util.c index ce53c7108a0d..5c9a2f2f6d8e 100644 --- a/usr.bin/mail/util.c +++ b/usr.bin/mail/util.c @@ -135,7 +135,7 @@ hfield(const char *field, struct message *mp) ibuf = setinput(mp); if ((lc = mp->m_lines - 1) < 0) return (NULL); - if (readline(ibuf, linebuf, LINESIZE) < 0) + if (readline(ibuf, linebuf, sizeof(linebuf)) < 0) return (NULL); while (lc > 0) { if ((lc = gethfield(ibuf, linebuf, lc, &colon)) < 0) @@ -184,7 +184,7 @@ gethfield(FILE *f, char linebuf[], int rem, char **colon) ungetc(c = getc(f), f); if (c != ' ' && c != '\t') break; - if ((c = readline(f, line2, LINESIZE)) < 0) + if ((c = readline(f, line2, sizeof(line2))) < 0) break; rem--; for (cp2 = line2; *cp2 == ' ' || *cp2 == '\t'; cp2++) @@ -503,7 +503,7 @@ name1(struct message *mp, int reptype) return (cp); ibuf = setinput(mp); namebuf[0] = '\0'; - if (readline(ibuf, linebuf, LINESIZE) < 0) + if (readline(ibuf, linebuf, sizeof(linebuf)) < 0) return (savestr(namebuf)); newname: for (cp = linebuf; *cp != '\0' && *cp != ' '; cp++) @@ -512,10 +512,10 @@ newname: ; for (cp2 = &namebuf[strlen(namebuf)]; *cp != '\0' && *cp != ' ' && *cp != '\t' && - cp2 < namebuf + LINESIZE - 1;) + cp2 < namebuf + sizeof(namebuf) - 1;) *cp2++ = *cp++; *cp2 = '\0'; - if (readline(ibuf, linebuf, LINESIZE) < 0) + if (readline(ibuf, linebuf, sizeof(linebuf)) < 0) return (savestr(namebuf)); if ((cp = strchr(linebuf, 'F')) == NULL) return (savestr(namebuf));