From nobody Tue Mar 3 22:51:11 2026 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 4fQWHn2FRqz6TlP5 for ; Tue, 03 Mar 2026 22:51:17 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fQWHn1K4Xz428k for ; Tue, 03 Mar 2026 22:51:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772578277; 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=Bv5Zd2D/69G3DFGcOCoRMZeXZrJfqsbv8XJrD2c29TI=; b=ivIfmkxblMb5QDjIg/4ZPdKK3I+qTQZKZkPUaVvm0iUxHo7zhL4CzvnH3abYgYYCYPwTw/ phP0Xh5H/Ru3kjxgO8t2mcS2iVRFSYI2YYQ+n2kjtgFciON2STjkWSAhm13fVV4K47VCeI EdgmAzmfBclmjNZnMjFUHGSCCS0ErfHI+aq7WDjvi93A1uBu4wOSV0aZMG07P8wIpuruCX k7i1hJH9dFdqNSem+arg+sib2izoxGGlqK2eS4mOATj6aZtS8IHslF//+fDrO0+w7Jgyz2 SUblIFFcN4vgHz/gGZc2oFsE9O9enTaz3xezDN/3dSDfRD3v7WhCHwMRDY/xmg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772578277; a=rsa-sha256; cv=none; b=LmHQobWEDGcAsVh2pNFVWUNWPdjEVoXfbTPmpjTu8OpesiO55NI0IR5i6ClSODcJklBZrD 2M/DdnQ39Bn+P2YRbAOcrF3+/tihIH2PIQAQJu00llzr3sWskb23xt0wKR3CtKdFuc3jLz pdOmeY+/WevIHGW4kC4QFpC5XNEHolSQ0+zUcVbG4MBroSfmNSp9pKXVGGtE5iMI5oMmOO 49Ki3X8GmLoS+EN+h1NnP2bPtdUqPAXR15L8lV9VhvyEvxgrDI7ZSzv+K/J2QwoLPojsnL iIEq3eoEqcUmIGnPeEGbvb8MY2cEsTO8ys+j4BMxTkKXUX6pLmAZhR3A1V7Opw== 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=1772578277; 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=Bv5Zd2D/69G3DFGcOCoRMZeXZrJfqsbv8XJrD2c29TI=; b=xpVB1d7kx2Gh1K1RAxBueHhg5jZocGdvN95dn71zHESNBTPj7txrA9R1HFG6qgk5oZFHfi bKloyZu07YK4hVsRmiflb1JRzst8QpjR+xGqZXZIWj2voIRjm027GQyAc3UTPDO3CmxhkS AWtVgmdJEStfPx3TlRQPCJ/lzgUiTCs4SnXmBa0/h+OMug+D4wDmyaXdF63i4IPLvjpDeW iwZZ+B+PTUsNpkT+SQFdWBs092Pc0LNRkA8WCnGTcT/etKnf/SpcZwQv+GUjkZ45CPMXFN TaoIHT1Ad0VCctBugPgEeCzyPLuR+PQS+2MeSvKzPr7/gBRAkjvhV+XSLFLHSQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fQWHn0r19z8fZ for ; Tue, 03 Mar 2026 22:51:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3abcc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 03 Mar 2026 22:51:11 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 7e70589b1bee - main - libutil: take a size_t in trimdomain() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 7e70589b1bee4853cb11e3d8eb963079b18ff534 Auto-Submitted: auto-generated Date: Tue, 03 Mar 2026 22:51:11 +0000 Message-Id: <69a765df.3abcc.3800efea@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=7e70589b1bee4853cb11e3d8eb963079b18ff534 commit 7e70589b1bee4853cb11e3d8eb963079b18ff534 Author: Kyle Evans AuthorDate: 2026-03-03 22:51:01 +0000 Commit: Kyle Evans CommitDate: 2026-03-03 22:51:01 +0000 libutil: take a size_t in trimdomain() INT_MAX is already larger than a reasonable hostname might be, but size_t makes some of this easier to reason about as we do arithmetic with it. This would maybe not be worth it if we had to bump the soversion because of it, but libutil does symbol versioning now so we can provide a compat shim. While we're here, fix some inconsistencies in argument names in the manpage. Reviewed by: des Obtained from: https://github.com/apple-oss-distributions/libutil Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D54622 --- lib/libutil/Symbol.map | 5 ++++- lib/libutil/libutil.h | 2 +- lib/libutil/trimdomain.3 | 8 ++++---- lib/libutil/trimdomain.c | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/libutil/Symbol.map b/lib/libutil/Symbol.map index 2b28456f4406..fbd10769b2a0 100644 --- a/lib/libutil/Symbol.map +++ b/lib/libutil/Symbol.map @@ -115,7 +115,6 @@ FBSD_1.8 { setclassenvironment; setclassresources; setusercontext; - trimdomain; uu_lock_txfr; uu_lock; uu_lockerr; @@ -130,6 +129,10 @@ FBSD_1.8 { crypt_set_format; }; +FBSD_1.9 { + trimdomain; +}; + FBSDprivate_1.0 { __pw_initpwd; }; diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index 9b5b2abe7f09..17e4f1fba247 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -140,7 +140,7 @@ int realhostname(char *_host, size_t _hsize, const struct in_addr *_ip); int realhostname_sa(char *_host, size_t _hsize, struct sockaddr *_addr, int _addrlen); int _secure_path(const char *_path, uid_t _uid, gid_t _gid); -void trimdomain(char *_fullhost, int _hostsize); +void trimdomain(char *_fullhost, size_t _hostsize); const char * uu_lockerr(int _uu_lockresult); int uu_lock(const char *_ttyname); diff --git a/lib/libutil/trimdomain.3 b/lib/libutil/trimdomain.3 index 114d8d139869..4a3a4d5827ec 100644 --- a/lib/libutil/trimdomain.3 +++ b/lib/libutil/trimdomain.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 17, 2025 +.Dd March 3, 2026 .Dt TRIMDOMAIN 3 .Os .Sh NAME @@ -34,7 +34,7 @@ .In sys/types.h .In libutil.h .Ft void -.Fn trimdomain "char *fullhost" "int hostsize" +.Fn trimdomain "char *fullhost" "size_t hostsize" .Sh DESCRIPTION The function .Fn trimdomain @@ -53,13 +53,13 @@ the first time this function is called and is cached for future use. The .Fn trimdomain function will only trim the domain name if the passed -.Ar fullname +.Ar fullhost ends with the current domain name and if the length of the resulting host name does not exceed .Ar hostsize . .Pp If the passed -.Ar fullname +.Ar fullhost is actually an X11 .Ev DISPLAY specification of the form diff --git a/lib/libutil/trimdomain.c b/lib/libutil/trimdomain.c index 77518a389419..47297817a76f 100644 --- a/lib/libutil/trimdomain.c +++ b/lib/libutil/trimdomain.c @@ -34,6 +34,7 @@ #include #include +void freebsd15_trimdomain(char *, int); static int isDISP(const char *); /*- @@ -50,7 +51,7 @@ static int isDISP(const char *); * trimdomain("abcde.my.domain:0.0", 8) -> "abcde.my.domain:0.0" */ void -trimdomain(char *fullhost, int hostsize) +trimdomain(char *fullhost, size_t hostsize) { static size_t dlen; static int first = 1; @@ -89,6 +90,21 @@ trimdomain(char *fullhost, int hostsize) } } +void +freebsd15_trimdomain(char *fullhost, int hostsize) +{ + /* + * Note that we intentionally aren't doing anything here about a + * negative `hostsize`, to preserve historical behavior. Functionally, + * it would have ended up as a very large size passing to the memchr(3), + * thus either appearing to work or reading off the end of the buffer if + * `fullhost` is actually malformed. + */ + trimdomain(fullhost, hostsize); +} + +__sym_compat(trimdomain, freebsd15_trimdomain, FBSD_1.8); + /* * Is the given string NN or NN.NN where ``NN'' is an all-numeric string ? */