From nobody Tue Mar 3 22:51:11 2026 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 4fQWHh4btmz6TlLl for ; Tue, 03 Mar 2026 22:51:12 +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 4fQWHg75fbz425K for ; Tue, 03 Mar 2026 22:51:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772578272; 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=BZVHajKnO2in25iBWY/IFfqO6jCahmRLplh9S6+RiN+Ycbz2dM8iUuv/a72ea5tzZj95AB JBiq9qlRzZIH+1cIxBEK1mYBsUbwr0PSc5QesLpWemNiOdUIH8LFz4HI9CDJUYj3ghoDL/ 6hSsoamBeM3vKFP0O5tM090D+eUVrT1vCExETPg3pTuqGI3KlH3Zuo+x1EXz+H+t4raTEh WlWTQ9iSaXAVURZg1h3j6j/btR/gADoG5pW6zN93ehcOmsPDOA4ClIgJ3fLy8uPSZaENy7 0x2d9N8u/JftXwAq29QWjJADDeIed/9X3wENb72HGe0WPU/QBEgNlUil1PNWJA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772578272; a=rsa-sha256; cv=none; b=UbShY3z7/CdbcJuTiFZKcqG8aqUIG+PM7vkCAEBr27xcmbnc5uLl3/rhGmA3w0btK491pS RXIOGmjjo9bmgGZnUfH45ngdfsOMHWYHfyI4WGN58kyy0bs7Bq4/d9rMPPyPRrARQk6sWZ 0cwciD+N03XGaVgK9zJz0+KGW/Ah4hRg2IWBZDlTtgooz5kjiHr/vznmuNGuLy6cnilGgV nEsZdILuE/aOIO6qV+PoWG6eTjMSB/Qii5TnH3KArxrpw8B4phyiWGINqCvkU6O0J+aO1S xOoAHucHoF5vz++3SmU+doScMZKTlIqGDcv9iVmCN4GfYIoTIiK7XHanS2jhag== 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=1772578272; 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=b/yR8zju/fce7IjQrcnB3Fi/fEiXy+lun9ytI55vVSr2qTH1RuICS6YCq2WwMxv2YonGa+ 8EBNqsM6/wOuqaXXF5rweseVA5scGwbqL5ZAf3+pT+Vf1yHZEcpnO/KJavbkT24fsVIQjz HHPsFt/4wJ5bm+14iDIhR65p1TkHF52YV/oAGiD4C+2Wtff+k0lxtXTDaw0aEIb02L9nER 9G9AcTxv2kHiBNmmXL64M6s24z2edm/erxZHen5a1moVu5eQAwu0xS9tb4UFm1hSC4oQQm +qWdwKk8Iz8VXE/kbcMT23g/nwDOXeyxsfUFjoZx8XqgGm6YtAwKYCjAyLFpSg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fQWHg6dmQz8qG for ; Tue, 03 Mar 2026 22:51:11 +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 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: 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 ? */