Skip to content

fuzz: replace unsafe libc::dup by rustix::io::dup#12148

Open
blixygetir wants to merge 15 commits intouutils:mainfrom
blixygetir:fix-unsafe
Open

fuzz: replace unsafe libc::dup by rustix::io::dup#12148
blixygetir wants to merge 15 commits intouutils:mainfrom
blixygetir:fix-unsafe

Conversation

@blixygetir
Copy link
Copy Markdown

Fixes #12110

Replaces unsafe libc::dup calls with the safe rustix::io::dup wrapper in fuzz/uufuzz/src/lib.rs. The code now uses Result instead of checking for -1, and leverages IntoRawFd to transfer ownership to raw i32 file descriptors, allowing them to be used throughout the function without auto-closing.

Copilot AI review requested due to automatic review settings May 4, 2026 20:35
@oech3

This comment was marked as resolved.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the uufuzz harness to avoid unsafe libc::dup by switching to the safe rustix::io::dup wrapper, adjusting fd handling accordingly.

Changes:

  • Replace libc::dup calls with rustix::io::dup in fuzz/uufuzz/src/lib.rs and adjust error handling/ownership transfer.
  • Add rustix as a dependency for uufuzz (and update fuzz/Cargo.lock).
  • Add a fuzz/rust-toolchain.toml setting the fuzz workspace toolchain to nightly.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.

File Description
fuzz/uufuzz/src/lib.rs Switch stdout/stderr/stdin duplication from libc::dup to rustix::io::dup and refactor fd handling.
fuzz/uufuzz/Cargo.toml Add rustix dependency needed for rustix::io::dup.
fuzz/rust-toolchain.toml Introduce a nightly toolchain pin for the fuzz workspace.
fuzz/Cargo.lock Lockfile update to include rustix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fuzz/uufuzz/src/lib.rs Outdated
Comment thread fuzz/uufuzz/src/lib.rs Outdated
Comment thread fuzz/uufuzz/src/lib.rs Outdated
Comment thread fuzz/uufuzz/src/lib.rs Outdated
Comment thread fuzz/rust-toolchain.toml Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/dd/no-allocate is now being skipped but was previously passing.
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.
Skip an intermittent issue tests/cut/bounded-memory (was skipped on 'main', now failing)

@oech3

This comment was marked as resolved.

blixygetir and others added 2 commits May 5, 2026 11:30
Co-authored-by: Copilot <copilot@github.com>
@blixygetir blixygetir force-pushed the fix-unsafe branch 2 times, most recently from 0e02b4f to 417d0a5 Compare May 5, 2026 14:41
Removes the unnecessary nightly toolchain requirement that was
causing CI failures. All code uses only stable Rust features.
This fixes clippy component availability issues on all platforms.
@blixygetir blixygetir force-pushed the fix-unsafe branch 3 times, most recently from 4a61ce4 to 5d00293 Compare May 5, 2026 15:43
@blixygetir blixygetir closed this May 5, 2026
@blixygetir blixygetir reopened this May 5, 2026
@blixygetir blixygetir closed this May 5, 2026
@blixygetir blixygetir reopened this May 5, 2026
@blixygetir blixygetir closed this May 6, 2026
@blixygetir blixygetir reopened this May 6, 2026
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.

fuzz: replace unsafe libc::dup by rustix::io::dup

3 participants