aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/wayland/wayland.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-16 03:34:05 +0900
committerOphestra <cat@gensokyo.uk>2025-11-16 03:34:05 +0900
commit38b5ff0cec266c7c5e423b68e8626f4a4a63d3ee (patch)
tree77d33091b0348c5a57cf328fa682ebb35aeaa99e /internal/wayland/wayland.go
parent3c204b9b40373d1f404b1a16e95fdfebb7d58832 (diff)
internal/wayland: check pathname size
This avoids passing a truncated pathname to the kernel. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/wayland/wayland.go')
-rw-r--r--internal/wayland/wayland.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/wayland/wayland.go b/internal/wayland/wayland.go
index f5113006..cc4f4e04 100644
--- a/internal/wayland/wayland.go
+++ b/internal/wayland/wayland.go
@@ -12,8 +12,8 @@ package wayland
*/
import "C"
import (
+ "errors"
"strings"
- "syscall"
)
const (
@@ -134,8 +134,11 @@ func securityContextBind(
appID, instanceID string,
closeFd int,
) error {
- if hasNull(appID) || hasNull(instanceID) {
- return syscall.EINVAL
+ if hasNull(socketPath) || hasNull(appID) || hasNull(instanceID) {
+ return &Error{Cause: RBind, Path: socketPath, Errno: errors.New("argument contains NUL character")}
+ }
+ if !C.hakurei_is_valid_size_sun_path(C.size_t(len(socketPath))) {
+ return &Error{Cause: RBind, Path: socketPath, Errno: errors.New("socket pathname too long")}
}
var e Error