Skip to content

Preserve pathname bytes in refcount unlink - #664

Merged
nunoplopes merged 2 commits into
masterfrom
perfloop-pr-open-t7m9f7wwjc
Nov 19, 2026
Merged

nunoplopes merged 2 commits into
masterfrom
perfloop-pr-open-t7m9f7wwjc

Conversation

@perfloop

@perfloop perfloop Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Refcount unlink can delete another file when a pathname contains non-UTF-8 bytes. Lossy text conversion can turn a missing byte-named target into the name of an existing file containing the UTF-8 replacement character.

rules/unistd/tgt_refcount.rs now passes the pathname through the existing with_c_bytes view directly to nix. This preserves the bytes up to the first NUL without changing the shared text-conversion helper. The success return and error-to-errno mapping stay unchanged, and the generated code remains safe Rust.

tests/unit/unlink_bytes.c creates a replacement-character sibling, attempts to unlink a distinct missing non-UTF-8 pathname, and checks the failure result, errno, and sibling survival. Expected refcount output is also regenerated for the affected existing unlink consumers.

Testing

Scoped lit tests for unlink and its affected generated-code consumers report 11 passed, 0 failed, and 0 skipped, exercising native C and both Rust models.

This change is limited to refcount unlink; other pathname rules are unchanged. macOS validation is left to target CI.

Case and evidence


Made by Perfloop.

Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
@nunoplopes
nunoplopes merged commit a087427 into master Nov 19, 2026
9 checks passed
@nunoplopes
nunoplopes deleted the perfloop-pr-open-t7m9f7wwjc branch November 19, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants