Skip to content

Commit 25ca307

Browse files
authored
Add preceding slash to shm_open (#324)
This should improve portability of this API, as stated in the man page: https://www.man7.org/linux/man-pages/man3/shm_open.3.html
1 parent 6dfeaa1 commit 25ca307

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/backends/wayland/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn create_memfile() -> File {
3737
let mut rng = fastrand::Rng::new();
3838

3939
for _ in 0..=4 {
40-
let mut name = String::from("softbuffer-");
40+
let mut name = String::from("/softbuffer-");
4141
name.extend(iter::repeat_with(|| rng.alphanumeric()).take(7));
4242
name.push('\0');
4343

src/backends/x11.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,13 +791,13 @@ fn create_shm_id() -> io::Result<OwnedFd> {
791791
use posix_shm::{Mode, OFlags};
792792

793793
let mut rng = fastrand::Rng::new();
794-
let mut name = String::with_capacity(23);
794+
let mut name = String::with_capacity(24);
795795

796796
// Only try four times; the chances of a collision on this space is astronomically low, so if
797797
// we miss four times in a row we're probably under attack.
798798
for i in 0..4 {
799799
name.clear();
800-
name.push_str("softbuffer-x11-");
800+
name.push_str("/softbuffer-x11-");
801801
name.extend(std::iter::repeat_with(|| rng.alphanumeric()).take(7));
802802

803803
// Try to create the shared memory segment.

0 commit comments

Comments
 (0)