aboutsummaryrefslogtreecommitdiffhomepage
path: root/wl
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-19 23:35:49 +0900
committerOphestra <cat@gensokyo.uk>2025-02-19 23:35:49 +0900
commitd0dff1cac96b9e509ce7aab011d9db684c356f9c (patch)
tree67ee9f78977d2b18e74511da916ea4daaef7b66e /wl
parent3c80fd2b0f907af7b179e9e307304c0fa52994a0 (diff)
wl: check against null character
Wayland library takes null terminated strings. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'wl')
-rw-r--r--wl/wl.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/wl/wl.go b/wl/wl.go
index 2eb0e89f..da1ed2c8 100644
--- a/wl/wl.go
+++ b/wl/wl.go
@@ -10,7 +10,14 @@ package wl
#include "wayland-bind.h"
*/
import "C"
-import "errors"
+import (
+ "errors"
+ "strings"
+)
+
+var (
+ ErrContainsNull = errors.New("string contains null character")
+)
var resErr = [...]error{
0: nil,
@@ -19,6 +26,11 @@ var resErr = [...]error{
}
func bindWaylandFd(socketPath string, fd uintptr, appID, instanceID string, syncFD uintptr) error {
+ if hasNull(appID) || hasNull(instanceID) {
+ return ErrContainsNull
+ }
res := C.bind_wayland_fd(C.CString(socketPath), C.int(fd), C.CString(appID), C.CString(instanceID), C.int(syncFD))
return resErr[int32(res)]
}
+
+func hasNull(s string) bool { return strings.IndexByte(s, '\x00') > -1 }