This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch feat/e-wl-proxy-planb
in repository enlightenment.

View the commit online.

commit 9834afb20be69bf50b55c151b095761884a5ccfc
Author: [email protected] <[email protected]>
AuthorDate: Sun Jun 7 22:40:50 2026 -0600

    feat(e_wl_proxy): runtime socket path helper
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 src/bin/e_wl_proxy/e_wl_proxy_socket.c     | 21 ++++++++++++++++++++-
 src/bin/e_wl_proxy/tests/e_wl_proxy_test.c | 19 +++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/bin/e_wl_proxy/e_wl_proxy_socket.c b/src/bin/e_wl_proxy/e_wl_proxy_socket.c
index bfc9105c3..5d4ba9580 100644
--- a/src/bin/e_wl_proxy/e_wl_proxy_socket.c
+++ b/src/bin/e_wl_proxy/e_wl_proxy_socket.c
@@ -1,6 +1,25 @@
 #include "config.h"
 #include "e_wl_proxy.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int
+e_wl_proxy_socket_path(const char *name, char *buf, size_t buflen)
+{
+   const char *runtime;
+   int n;
+
+   if (!name || name[0] == '\0' || strchr(name, '/')) return -1;
+
+   runtime = getenv("XDG_RUNTIME_DIR");
+   if (!runtime || runtime[0] == '\0') return -1;
+
+   n = snprintf(buf, buflen, "%s/%s", runtime, name);
+   if (n < 0 || (size_t)n >= buflen) return -1;
+
+   return 0;
+}
 
-int e_wl_proxy_socket_path(const char *name, char *buf, size_t buflen) { (void)name; (void)buf; (void)buflen; return -1; }
 int e_wl_proxy_listen(const char *name) { (void)name; return -1; }
 int e_wl_proxy_connect(const char *name) { (void)name; return -1; }
diff --git a/src/bin/e_wl_proxy/tests/e_wl_proxy_test.c b/src/bin/e_wl_proxy/tests/e_wl_proxy_test.c
index c83923aeb..9616a8748 100644
--- a/src/bin/e_wl_proxy/tests/e_wl_proxy_test.c
+++ b/src/bin/e_wl_proxy/tests/e_wl_proxy_test.c
@@ -1,6 +1,7 @@
 #include "e_wl_proxy.h"
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 static int failures = 0;
 
@@ -10,10 +11,28 @@ static int failures = 0;
 
 static void test_harness_runs(void) { CHECK(1 == 1); }
 
+static void
+test_socket_path(void)
+{
+   char buf[256];
+
+   setenv("XDG_RUNTIME_DIR", "/run/user/1000", 1);
+   CHECK(e_wl_proxy_socket_path("wayland-0", buf, sizeof(buf)) == 0);
+   CHECK(strcmp(buf, "/run/user/1000/wayland-0") == 0);
+
+   /* reject names that would escape the runtime dir */
+   CHECK(e_wl_proxy_socket_path("../evil", buf, sizeof(buf)) == -1);
+   CHECK(e_wl_proxy_socket_path("", buf, sizeof(buf)) == -1);
+
+   /* reject overflow */
+   CHECK(e_wl_proxy_socket_path("wayland-0", buf, 8) == -1);
+}
+
 int
 main(void)
 {
    test_harness_runs();
+   test_socket_path();
    if (failures) { fprintf(stderr, "%d check(s) failed\n", failures); return 1; }
    printf("all checks passed\n");
    return 0;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to