Skip to content

Commit

Permalink
Merge pull request #5 from ryanavella/null-byte-check
Browse files Browse the repository at this point in the history
Reject names with null-bytes in NamedLock::create.
  • Loading branch information
oblique authored Sep 1, 2022
2 parents 9902570 + 50ce98d commit 20c0f21
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ impl NamedLock {
// so we block the `/` character.
//
// On Windows `\` character is invalid.
if name.contains('/') || name.contains('\\') {
//
// Both platforms expect null-terminated strings,
// so we block null-bytes.
if name.chars().any(|c| matches!(c, '\0' | '/' | '\\')) {
return Err(Error::InvalidCharacter);
}

Expand Down

0 comments on commit 20c0f21

Please sign in to comment.