From nobody Wed Sep 18 16:30:15 2024 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 4X83zC2cNxz5WlC5; Wed, 18 Sep 2024 16:30:15 +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 4X83zC1B5nz4S0W; Wed, 18 Sep 2024 16:30:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726677015; 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=xPJtYPPmy9Sib3x8pLq9dYaSSgxBzMsoH49BzGMgNpw=; b=PMvp9Zi1iSoYR14BLyxRKZPQSNMxlHNev8RgiVmMH7sJuLSXg9EV/nv38XsOaqht+J08nQ o2K9vIiLn/FF0I6dFBx1jZ0XVSBECnJuTklO9jYR80tFAOmteldzabX9ARvI6+xUcnB8kA +4KB8bQ44gOkoHeOY0XhNWuIDFCOp0ure5htHbUVwRm2w7uoXk+UaK4rZEgP3a7GulzRqV ikzgSTUjoIY7LuiUjv98pBmfjoWfJG0N9petGw+nUAhAy1qnFHS//laJRYJOc+5kyxKBWn DiY8kOJOLw9IS5gU9sRRYnVytiQJU5R7YIBxSMrL5hvEPlCpCZfrV+r5ArV4xg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726677015; a=rsa-sha256; cv=none; b=J92ifjuZQvwyYtNf3d4fayf+yz6KKg8OEHclvqhALrPGmZyvvBvHR9EmkNATWs5kbwrsVN jnUqbgikZgCYEC8Blfz7AqaRYusMaUhVi1x4De7MTkd9nlV2JeGMSnjteCTCkkO6D/M/d6 eNmEWct6JnoPfI1Xdxqv/357ra4mhPEiEZojGIZfl4w/5+f8WqKfJKX+GcMHQTcrCi9p77 hF2X59MHpD3KVA3rXLyBL58/879sAdiY2fqJ2WlmvaOFlKJLTfulwqKy1kLucaXgmzpPS5 h0oIH90qs1tCxKjPBWQQ5uLHGPVwi9RLXmWeMmkHgtXlMTqxpytMFny1U7p8Nw== 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=1726677015; 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=xPJtYPPmy9Sib3x8pLq9dYaSSgxBzMsoH49BzGMgNpw=; b=G0hrSUAHeOqMzFzo6MuRmtbfUWQFia2AjZ5Iu/Lbbo3jXSQ8DYunQDx7kzySQd8kBpTk4x Oehg3cxAuUtzRjWGchZwRykgT+UW/Frx2exdhlGiLTN07BjXjpXOBaH5S18CmV0No+wYoO TSuKBCgo9X3A+nk7+glWovPvIj9PaDcF5EJPrzDB3esTHdPh+f6URfyxOJ8r+Hj7NQxZan UKXS+roo4HQYUBtKGTuC1UVZnxxxzgRWo+8RKMNwxNw0aePpxrweZG8LRe6tAI6v49x2Sb 9HF6IncLoDxiubqmN0wojCYewXOunN207Xiuc0RqL+FKQanjsQ2LmJLUgrmhbg== 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 4X83zC0npVzTm2; Wed, 18 Sep 2024 16:30:15 +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 48IGUF1Y098806; Wed, 18 Sep 2024 16:30:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48IGUFZS098803; Wed, 18 Sep 2024 16:30:15 GMT (envelope-from git) Date: Wed, 18 Sep 2024 16:30:15 GMT Message-Id: <202409181630.48IGUFZS098803@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: abed32f91d01 - main - realpath(3): Minor style issues. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: abed32f91d01d91faa709622e3279e9baec37272 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=abed32f91d01d91faa709622e3279e9baec37272 commit abed32f91d01d91faa709622e3279e9baec37272 Author: Dag-Erling Smørgrav AuthorDate: 2024-09-18 16:29:55 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-09-18 16:29:55 +0000 realpath(3): Minor style issues. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D46695 --- lib/libc/stdlib/realpath.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 554d70b43a29..28348ea9e226 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -33,10 +33,10 @@ #include #include +#include #include #include #include -#include #include #include "un-namespace.h" #include "libc_private.h" @@ -146,13 +146,14 @@ realpath1(const char *path, char *resolved) return (NULL); } slen = readlink(resolved, symlink, sizeof(symlink)); - if (slen <= 0 || slen >= (ssize_t)sizeof(symlink)) { - if (slen < 0) - ; /* keep errno from readlink(2) call */ - else if (slen == 0) - errno = ENOENT; - else - errno = ENAMETOOLONG; + if (slen < 0) + return (NULL); + if (slen == 0) { + errno = ENOENT; + return (NULL); + } + if ((size_t)slen >= sizeof(symlink)) { + errno = ENAMETOOLONG; return (NULL); } symlink[slen] = '\0'; @@ -173,7 +174,7 @@ realpath1(const char *path, char *resolved) */ if (p != NULL) { if (symlink[slen - 1] != '/') { - if (slen + 1 >= (ssize_t)sizeof(symlink)) { + if ((size_t)slen + 1 >= sizeof(symlink)) { errno = ENAMETOOLONG; return (NULL); }