Skip to content

fix(lock): sanitize WAYLAND_DISPLAY in lockfile path - #197

Open
re2zero wants to merge 1 commit into
emersion:masterfrom
re2zero:fix/issue-188-lockfile-path
Open

fix(lock): sanitize WAYLAND_DISPLAY in lockfile path#197
re2zero wants to merge 1 commit into
emersion:masterfrom
re2zero:fix/issue-188-lockfile-path

Conversation

@re2zero

@re2zero re2zero commented May 28, 2026

Copy link
Copy Markdown

Summary

  • Sanitize WAYLAND_DISPLAY by replacing / with - before constructing the lockfile path

Problem

When WAYLAND_DISPLAY contains a slash (e.g. wl/wayland-1), the lockfile path becomes $XDG_RUNTIME_DIR/slurp-wl/wayland-1.lock. The wl/ subdirectory may not exist, causing open() to fail with "failed to open lock file".

Fix

Replace / with - in WAYLAND_DISPLAY before constructing the path, so wl/wayland-1 becomes wl-wayland-1, producing a valid flat path $XDG_RUNTIME_DIR/slurp-wl-wayland-1.lock.

Changes

File Change
lock.c Sanitize WAYLAND_DISPLAY, replacing / with -

Fixes #188

When WAYLAND_DISPLAY contains a slash (e.g. wl/wayland-1),
the lockfile path would include a subdirectory component that
may not exist, causing open() to fail.

Replace '/' with '-' in WAYLAND_DISPLAY before constructing
the lockfile path.

Fixes emersion#188
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.

fails to acquire lock if WAYLAND_DISPLAY contains a /

1 participant