libarchive: Handle UTF-8 filenames without locale dependency#3559
Merged
cgwalters merged 1 commit intoostreedev:mainfrom Jan 30, 2026
Merged
libarchive: Handle UTF-8 filenames without locale dependency#3559cgwalters merged 1 commit intoostreedev:mainfrom
cgwalters merged 1 commit intoostreedev:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request correctly addresses an issue with handling non-ASCII UTF-8 filenames in libarchive when the locale is POSIX/C. The strategy of using _utf8 function variants with a fallback to manual validation is a solid approach. The new test case is also a valuable addition, ensuring the fix is effective.
I have identified a couple of critical issues in the implementation that could lead to crashes or re-introduce the bug this PR aims to fix. I've also pointed out a minor inefficiency. My review comments include specific code suggestions to resolve these problems. After addressing these points, the pull request will be much stronger.
When importing archives (including OCI container layers), libarchive attempts to convert filenames from UTF-8 to the current locale charset. In POSIX/C locale (which uses ASCII), this conversion fails for any non-ASCII UTF-8 characters, returning ARCHIVE_WARN. This is triggered by Python 3.14 which creates a "𝜋thon" symlink in venvs, and affects bootc installations in environments where LANG is not set (defaulting to POSIX locale). Fix this by: 1. Using archive_entry_pathname_utf8() and archive_entry_symlink_utf8() which return UTF-8 directly without locale conversion 2. Falling back to the regular accessors with explicit UTF-8 validation when the _utf8 variants return NULL 3. Accepting ARCHIVE_WARN from archive_read_next_header() since we now validate UTF-8 ourselves rather than relying on libarchive charset conversion This matches the behavior of GNU tar which treats filenames as opaque bytes without charset conversion. Closes: ostreedev#3431
d416642 to
2fb1114
Compare
This was referenced Feb 16, 2026
4 tasks
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.
When importing archives (including OCI container layers), libarchive attempts to convert filenames from UTF-8 to the current locale charset. In POSIX/C locale (which uses ASCII), this conversion fails for any non-ASCII UTF-8 characters, returning ARCHIVE_WARN.
This is triggered by Python 3.14 which creates a "𝜋thon" symlink in venvs, and affects bootc installations in environments where LANG is not set (defaulting to POSIX locale).
Fix this by:
Using archive_entry_pathname_utf8() and archive_entry_symlink_utf8() which return UTF-8 directly without locale conversion
Falling back to the regular accessors with explicit UTF-8 validation when the _utf8 variants return NULL
Accepting ARCHIVE_WARN from archive_read_next_header() since we now validate UTF-8 ourselves rather than relying on libarchive charset conversion
This matches the behavior of GNU tar which treats filenames as opaque bytes without charset conversion.
Closes: #3431