Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Unsound usages of unsafe implementation about c_void

Open
#27 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
networking

Research direction

Start with src/netmap_user.rs:16 and the _NETMAP_OFFSET function, then review Rust’s undefined-behavior requirements for raw-pointer offset, alignment, and bounds. Validate the static-analyzer report against the function’s callers and determine whether the reported conversion can produce the claimed memory-safety issue. Done means the finding has a clear resolution and appropriate verification.

Written by the indexing model from the issue text.

Description

Hi, I am scanning this crate in the latest version using my own static analyzer tool.

Unsafe pointer conversion is found at: src/netmap_user.rs:16

pub unsafe fn _NETMAP_OFFSET<T, U>(ptr: *mut U, offset: isize) -> *mut T {
    ((ptr as *mut c_char).offset(offset) as *mut c_void) as *mut T
}

This unsound implementation would create memory issues such as overflow, underflow, or misalignment, since the type is converted to c_void (1 byte, 8 bits). The attacker can manipulate the argument offset associated with the c_void pointer with a large value, as well as T and U, which can lead to a buffer overflow bug.

This would cause undefined behaviors in Rust. Adversaries can manipulate the associated arguments to cause memory safety bugs. I am reporting this issue for your attention.

Dominant language
Rust
Stars
28
Forks
11
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libpnet/netmap_sys

All issues in libpnet/netmap_sys

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.