Skip to content

fix: reject invalid Linux core ids#12

Open
Sieger9303 wants to merge 1 commit into
elast0ny:masterfrom
Sieger9303:fix-invalid-core-id-panic
Open

fix: reject invalid Linux core ids#12
Sieger9303 wants to merge 1 commit into
elast0ny:masterfrom
Sieger9303:fix-invalid-core-id-panic

Conversation

@Sieger9303
Copy link
Copy Markdown

fix #11.

Hi, thanks for maintaining this crate.

set_thread_affinity currently passes each user-provided core id directly to CPU_SET. On Linux, very large invalid core ids can make CPU_SET index outside the backing cpu_set_t storage and panic before sched_setaffinity has a chance to return an error.

This PR adds a bounds check before calling CPU_SET, returning an Err for invalid core ids instead of panicking. =

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.

function set_thread_affinity() has a potential index out of bounds issue without pre-checking

1 participant