Skip to content

Commit 8844a1f

Browse files
embhornclaude
andcommitted
Fix CI: guard cloexec wrappers for linuxkm/Windows/OS2
Exclude WOLFSSL_LINUXKM from the POSIX wrapper block so kernel builds don't try to include <fcntl.h>/<sys/socket.h>. For platforms without POSIX close-on-exec (Windows, OS/2 Open Watcom, linuxkm, Zephyr), define the wrappers as macros that pass through to plain syscalls, letting call sites stay unconditional. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 7aab6e5 commit 8844a1f

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

wolfcrypt/src/wc_port.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
*/
2121

2222
#if (defined(__linux__) || defined(__ANDROID__)) && \
23-
!defined(WOLFSSL_ZEPHYR) && !defined(_GNU_SOURCE)
23+
!defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR) && \
24+
!defined(_GNU_SOURCE)
2425
#define _GNU_SOURCE 1
2526
#endif
2627

@@ -5135,7 +5136,8 @@ char* wolfSSL_strnstr(const char* s1, const char* s2, unsigned int n)
51355136

51365137
#endif /* not SINGLE_THREADED */
51375138

5138-
#if (defined(__unix__) || defined(__APPLE__)) && !defined(WOLFSSL_ZEPHYR)
5139+
#if (defined(__unix__) || defined(__APPLE__)) && \
5140+
!defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR)
51395141

51405142
#include <fcntl.h>
51415143
#include <errno.h>
@@ -5202,7 +5204,7 @@ int wc_accept_cloexec(int sockfd, void* addr, void* addrlen)
52025204
return fd;
52035205
}
52045206

5205-
#endif /* __unix__ || __APPLE__ */
5207+
#endif /* (__unix__ || __APPLE__) && !WOLFSSL_LINUXKM && !WOLFSSL_ZEPHYR */
52065208

52075209
#if defined(WOLFSSL_LINUXKM) && defined(CONFIG_ARM64) && \
52085210
defined(WC_SYM_RELOC_TABLES)

wolfssl/wolfcrypt/wc_port.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,11 +1860,22 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
18601860
#define WC_GENERATE_SEED_DEFAULT wc_GenerateSeed
18611861
#endif
18621862

1863-
#if (defined(__unix__) || defined(__APPLE__)) && !defined(WOLFSSL_ZEPHYR)
1863+
#if (defined(__unix__) || defined(__APPLE__)) && \
1864+
!defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR)
18641865
WOLFSSL_LOCAL void wc_set_cloexec(int fd);
18651866
WOLFSSL_LOCAL int wc_open_cloexec(const char* path, int flags);
18661867
WOLFSSL_LOCAL int wc_socket_cloexec(int domain, int type, int protocol);
18671868
WOLFSSL_LOCAL int wc_accept_cloexec(int sockfd, void* addr, void* addrlen);
1869+
#else
1870+
/* Platforms without POSIX close-on-exec semantics (Windows, OS/2 OW,
1871+
* Linux kernel module, Zephyr, etc.): pass through to plain syscalls
1872+
* where the underlying headers are available in the caller. */
1873+
#define wc_set_cloexec(fd) ((void)(fd))
1874+
#define wc_open_cloexec(path, flags) open((path), (flags))
1875+
#define wc_socket_cloexec(domain, type, protocol) \
1876+
socket((domain), (type), (protocol))
1877+
#define wc_accept_cloexec(sockfd, addr, addrlen) \
1878+
accept((sockfd), (addr), (addrlen))
18681879
#endif
18691880

18701881
#ifdef __cplusplus

0 commit comments

Comments
 (0)