From 454bee3f0237424f9a54c9007f0fb983b52c8173 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 7 Feb 2024 02:13:21 +0200 Subject: [PATCH] LibC: Fix sockaddr_un implementation --- libc/include/sys/socket.h | 8 +++++++- libc/include/sys/un.h | 4 ++-- libc/sys/socket.cpp | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h index 805fa058..f4e88e98 100644 --- a/libc/include/sys/socket.h +++ b/libc/include/sys/socket.h @@ -16,6 +16,12 @@ __BEGIN_DECLS #include typedef long socklen_t; +#if !defined(FILENAME_MAX) + #define FILENAME_MAX 256 +#elif FILENAME_MAX != 256 + #error "invalid FILENAME_MAX" +#endif + struct sockaddr { sa_family_t sa_family; /* Address family. */ @@ -24,8 +30,8 @@ struct sockaddr struct sockaddr_storage { - // FIXME sa_family_t ss_family; + char ss_storage[FILENAME_MAX]; }; struct msghdr diff --git a/libc/include/sys/un.h b/libc/include/sys/un.h index d1d538e6..7bddc493 100644 --- a/libc/include/sys/un.h +++ b/libc/include/sys/un.h @@ -11,8 +11,8 @@ __BEGIN_DECLS struct sockaddr_un { - sa_family_t sun_family; /* Address family. */ - char sun_path[]; /* Socket pathname. */ + sa_family_t sun_family; /* Address family. */ + char sun_path[FILENAME_MAX]; /* Socket pathname. */ }; __END_DECLS diff --git a/libc/sys/socket.cpp b/libc/sys/socket.cpp index 82b778a3..e9580ce4 100644 --- a/libc/sys/socket.cpp +++ b/libc/sys/socket.cpp @@ -22,7 +22,7 @@ int listen(int socket, int backlog) return syscall(SYS_LISTEN, socket, backlog); } -ssize_t revc(int socket, void* __restrict buffer, size_t length, int flags) +ssize_t recv(int socket, void* __restrict buffer, size_t length, int flags) { return recvfrom(socket, buffer, length, flags, nullptr, nullptr); }