From nobody Tue Nov 17 11:56:50 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 4jTNW703fsz71Jxh for ; Tue, 17 Nov 2026 11:56:51 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTNW64qH6z4HRx for ; Tue, 17 Nov 2026 11:56:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794916610; 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=x2dSacuCp90eX9pHBm7Wn0v71+41yvRAFaRLuT7tANg=; b=HP/cVwClKMj97MAAEhTbSB2EkAUE12AcMHofIpVnVfd1WymEguak69RuC0CHqg3+lYLBf4 yaf4+UueGvoEdnPDd4Llm/B/6ki2ykzKnmw2Mzr2VSQ9jwOSBah+C1lc+pLWYz0qnSA74T ySasOssWDpTY7rFvFDdvyegQBj5EHhxVIGy/nDEICYkITbRL/iKZ2Gn1d+1GNr5tXUhW4+ B1ZZTq/GiLKl3zu5DPQm1Ny0sX5dsVVV4LSCwHBUURYN2TlBlgqlgdwSlQuIhqaDfvcB5s ySzPfN5gMM+/tTgIJefaAdFYl0HG7aJMWbYi8UVPwopppenW2KuguWW6fBK5qg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794916610; b=pZLixpXuZmNfLtVwXBMhAw0Ochc3hQvU1szZ2ZblrBwqgrO3prVnZuef0FVAJB2AKtnsBc Kp4asvXbBW8WY24hYqNT0BeKUBphtriNh27dTG76NCb9AmUG7OsGJWtUsnohfmho7iPt4F nTWZD2AdCbtRxRqyDVJ5d3tFmPulxoya7qvTY9WOJAqUhGEeKNBPD996FQa0qwS0T4wqgn RSYTgqmdLniItDmdEkFybrs4R1aWyLBiFqzwEF66xSHbsoziVZBE4K0walqVzDe15oUBAZ DXW2a1Y/EZxKXxlRTWOsPFLhUZ/FFhjv+IFqzjpYJFm8ZeZIMkXZHDC3qFFH6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794916610; 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=x2dSacuCp90eX9pHBm7Wn0v71+41yvRAFaRLuT7tANg=; b=c+y8EBXhs+iBf1VVsLpAbOpmdJ2bC6jjH1QxDUUCYC8UpTDSJAOafVEllDX1Mx0G8WHxQn kxmWS/AS0hy0tmKF39L0raEchjSFXqqDIdaXRdtdjhxe7FhIDS3C8gDXpC6wLjHkqPaJ4A SEEsmpZTMsxf4sPXaTZjDpqZlyAqZONeaU1wyBYZ6cmZXwlnE7mKNOMyu8XtZBPE5SDA0T 1TwtKpPv9EtengSx4JofXlOQyqp6Jl9nQu+GtHyi2gGrdVfAOfh4IUr9tR0kTmJ2FEEsSQ dntKBDtfu9X84OBWK6v3maSr455YqTINPsjXtZ95Awnq0OicJ/XL/BPcOVnLbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTNW64Hzszh2d for ; Tue, 17 Nov 2026 11:56:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d35c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 11:56:50 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 5b952262d3e2 - main - pkg-serve: do not leak whether a path exists List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5b952262d3e223c033849441320bb12796bc52e4 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 11:56:50 +0000 Message-Id: <6afc4102.1d35c.421bcb4d@gitrepo.freebsd.org> The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=5b952262d3e223c033849441320bb12796bc52e4 commit 5b952262d3e223c033849441320bb12796bc52e4 Author: Baptiste Daroussin AuthorDate: 2026-11-17 11:52:17 +0000 Commit: Baptiste Daroussin CommitDate: 2026-11-17 11:55:19 +0000 pkg-serve: do not leak whether a path exists Report "ko: file not found" for non-regular files as well, so a client cannot tell an existing path from a missing one. --- libexec/pkg-serve/pkg-serve.c | 2 +- libexec/pkg-serve/tests/pkg_serve_test.sh | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/libexec/pkg-serve/pkg-serve.c b/libexec/pkg-serve/pkg-serve.c index cbe3c7689a93..b087f9971c3f 100644 --- a/libexec/pkg-serve/pkg-serve.c +++ b/libexec/pkg-serve/pkg-serve.c @@ -174,7 +174,7 @@ main(int argc, char *argv[]) if (!S_ISREG(st.st_mode)) { close(ffd); - printf("ko: not a file\n"); + printf("ko: file not found\n"); fflush(stdout); continue; } diff --git a/libexec/pkg-serve/tests/pkg_serve_test.sh b/libexec/pkg-serve/tests/pkg_serve_test.sh index 60ab92e2114c..9015209fa6e7 100644 --- a/libexec/pkg-serve/tests/pkg_serve_test.sh +++ b/libexec/pkg-serve/tests/pkg_serve_test.sh @@ -112,8 +112,8 @@ get_directory_head() get_directory_body() { mkdir -p repo/subdir - check_output "ko: not a file" "get subdir 0\nquit\n" repo || - atf_fail "expected not a file" + check_output "ko: file not found" "get subdir 0\nquit\n" repo || + atf_fail "expected file not found" } atf_test_case get_missing_age @@ -163,14 +163,29 @@ get_fifo_body() mkfifo repo/fifo output=$(printf 'get fifo 0\nquit\n' | timeout 10 "${PKG_SERVE}" repo) case "$output" in - *"ko: not a file"*) + *"ko: file not found"*) ;; *) - atf_fail "expected 'not a file', got: ${output}" + atf_fail "expected 'file not found', got: ${output}" ;; esac } +atf_test_case no_existence_oracle +no_existence_oracle_head() +{ + atf_set "descr" "Missing and non-regular files are indistinguishable" +} +no_existence_oracle_body() +{ + mkdir repo + mkdir repo/dir + missing=$(serve "get missing.pkg 0\nquit\n" repo) + nonreg=$(serve "get dir 0\nquit\n" repo) + [ "${missing}" = "${nonreg}" ] || + atf_fail "responses differ: '${missing}' vs '${nonreg}'" +} + atf_test_case path_traversal path_traversal_head() { @@ -271,6 +286,7 @@ atf_init_test_cases() atf_add_test_case get_file_leading_slash atf_add_test_case get_file_uptodate atf_add_test_case get_directory + atf_add_test_case no_existence_oracle atf_add_test_case get_missing_age atf_add_test_case get_bad_age atf_add_test_case get_empty_arg