From bc8273fc13aaa94136bf64a9805db93e8a5115ad Mon Sep 17 00:00:00 2001 From: Emma Stensland Date: Wed, 28 Oct 2026 15:15:13 -0600 Subject: [PATCH] random: include unistd.h wherever getpid() is used Only the default seed-source branch included it, so --enable-leanpsk (NO_DEV_RANDOM) called getpid() undeclared, which GCC 14 rejects. --- .github/configs/os-check-linux.json | 8 +++++++- wolfcrypt/src/random.c | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/configs/os-check-linux.json b/.github/configs/os-check-linux.json index 06c69fe9e9f..4b01c481131 100644 --- a/.github/configs/os-check-linux.json +++ b/.github/configs/os-check-linux.json @@ -573,5 +573,11 @@ "run": [["./wolfcrypt/test/testwolfcrypt"]]}, {"name": "postauth-no-compat", "comment": "Post-handshake auth without OPENSSL_EXTRA, which otherwise compiles out the handshake-end unload of SSL-owned certs and keys.", - "configure": ["--enable-postauth", "--enable-sessioncerts"]} + "configure": ["--enable-postauth", "--enable-sessioncerts"]}, +{"name": "leanpsk", + "comment": "The NO_DEV_RANDOM seed path includes no system headers, so this catches an undeclared getpid() on GCC 13 too. The test-seed #warning fails -Werror and -pedantic, so extra_cflags repeats the global set minus -pedantic (and -Wno-overlength-strings, which only matters with it) and downgrades the #warning.", + "configure": ["--enable-leanpsk"], + "extra_cflags": "-Wdeclaration-after-statement -Wnull-dereference -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -Werror=implicit-function-declaration -Wno-error=cpp", + "check": false, + "run": [["./wolfcrypt/test/testwolfcrypt"]]} ] diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index a30111f04a2..5e19aebd699 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -245,6 +245,11 @@ This library contains implementation for the random number generator. #endif #endif +#if defined(HAVE_GETPID) && !defined(WOLFSSL_NO_GETPID) + /* For getpid(): not every seed source above includes unistd.h. */ + #include +#endif + #if defined(WOLFSSL_TI_AM64X_R5) #include #endif