aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/wayland/wayland-client-helper.h
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-client-helper.h
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-client-helper.h')
-rw-r--r--internal/wayland/wayland-client-helper.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/wayland/wayland-client-helper.h b/internal/wayland/wayland-client-helper.h
index 5cdf0334..0a2cffb7 100644
--- a/internal/wayland/wayland-client-helper.h
+++ b/internal/wayland/wayland-client-helper.h
@@ -1,3 +1,6 @@
+#include <stdbool.h>
+#include <sys/un.h>
+
typedef enum {
HAKUREI_WAYLAND_SUCCESS,
/* wl_display_connect_to_fd failed, errno */
@@ -29,3 +32,9 @@ hakurei_wayland_res hakurei_security_context_bind(
const char *app_id,
const char *instance_id,
int close_fd);
+
+/* returns whether the specified size fits in the sun_path field of sockaddr_un */
+static inline bool hakurei_is_valid_size_sun_path(size_t sz) {
+ struct sockaddr_un sockaddr;
+ return sz <= sizeof(sockaddr.sun_path);
+};