Repository navigation
fix: verify PDFium archives and download them atomically - #69
Merged
Merged
Conversation
tools/download-pdfium.R downloaded straight into its persistent cache. Two failure modes are reproduced: - An interrupted transfer (half an archive served from a local HTTP server) left a partial file. R's libcurl code deletes the destination only when no bytes arrived, so every later install took the "Using cached archive" branch and failed. - A truncated cached archive was worse: utils::untar() only warns when tar fails, so the script exited 0 and left a truncated libpdfium.so in inst/lib for the link step to trip over. Now: - tools/pdfium-checksums.txt pins the SHA-256 of every archive detect_platform() can request, with a release: line that must match tools/pdfium-version.txt. The install stops if the file is for another release, has no entry for the archive, or is malformed. This is a mechanical gate for pin bumps. - tools/update-pdfium-checksums.R regenerates the file. Its output for chromium/8066 equals GitHub's published asset digests. - Every archive (downloaded, cached or vendored) is verified before it is unpacked. On R >= 4.5 that is an exact SHA-256 match. Older R has no tools::sha256sum(), so it only checks that the archive lists completely, and says so. - Downloads go to a temporary file in the cache directory and are renamed into place only after they verify. - A bad cache entry is replaced. A bad vendored archive or download stops the install. - Warnings while unpacking are errors. ADR-027 records this. It supersedes ADR-003's unimplemented "sentinel filename" consequence and ADR-006's rejection of hash pinning, which rested on the same false premise. dev/architecture.md's bump procedure gains the regeneration step. The new tests run the script offline against synthetic archives, using file:// URLs for the download path. Five of them fail against the previous script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the drop-CRAN docs (ADR-026). Only the ADR index conflicted: the ADR-003 status cell now names both superseding decisions (ADR-026 for the CRAN-submission wording, ADR-027 for the download-integrity consequence), and the ADR-026 and ADR-027 rows stay in number order. Rcpp exports and roxygen output are unchanged; the full suite passes under MALLOC_CHECK_=3 (3354 passed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tools/download-pdfium.R downloaded straight into its persistent cache.
Two failure modes are reproduced:
server) left a partial file. R's libcurl code deletes the
destination only when no bytes arrived, so every later install took
the "Using cached archive" branch and failed.
tar fails, so the script exited 0 and left a truncated libpdfium.so
in inst/lib for the link step to trip over.
Now:
detect_platform() can request, with a release: line that must match
tools/pdfium-version.txt. The install stops if the file is for
another release, has no entry for the archive, or is malformed. This
is a mechanical gate for pin bumps.
chromium/8066 equals GitHub's published asset digests.
is unpacked. On R >= 4.5 that is an exact SHA-256 match. Older R has
no tools::sha256sum(), so it only checks that the archive lists
completely, and says so.
renamed into place only after they verify.
stops the install.
ADR-027 records this. It supersedes ADR-003's unimplemented "sentinel
filename" consequence and ADR-006's rejection of hash pinning, which
rested on the same false premise. dev/architecture.md's bump procedure
gains the regeneration step. The new tests run the script offline
against synthetic archives, using file:// URLs for the download path.
Five of them fail against the previous script.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com