[Breaking] nvm_compare_checksum: refuse a file whose checksum cannot be verified

The empty-computed-sum branch ended with a bare `return`,
whose status is that of the preceding `nvm_err`, which is 0.
Callers treat 0 as "verified",
so an artifact that could not be verified was installed anyway,
and was even moved into the verified cache slot,
violating nvm.sh's own invariant that only a verified archive may sit at ${TARBALL}
(a later `--offline` install would then use it without any verification).

Return 1 so the artifact is rejected, as intended by #1858.

Fixes #1858

Signed-off-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
NUAAwqyandJordan Harband authored and Jordan Harband committed 2026-11-06 03:13:03 +00:00
1 parent 015c4f1e3b
commit 362f5e2c71
4 files changed
+22 -6

No files matched your search

+2 -2
View File
@@ -33,9 +33,9 @@ EXPECTED_OUTPUT='Provided checksum to compare to is empty.'
try_err nvm_compare_checksum ../../../nvm.sh checksum
EXPECTED_OUTPUT="Computed checksum of '../../../nvm.sh' is empty.
WARNING: Continuing *without checksum verification*"
Refusing to continue *without checksum verification*"
[ "${CAPTURED_STDERR}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${CAPTURED_STDERR}<"
[ "${CAPTURED_EXIT_CODE}" = 0 ] || die "expected to exit with code 0, got ${CAPTURED_EXIT_CODE}"
[ "${CAPTURED_EXIT_CODE}" = 1 ] || die "expected to exit with code 1, got ${CAPTURED_EXIT_CODE}"
nvm_compute_checksum() {
echo "not checksum: ${1}"