random: scope environ extern to macOS, BSDs and Illumos
What changed, and why it matters
This is a minor build-fix patch. It narrows which operating systems need a special declaration to access the program's environment variables during randomness collection. Previously the declaration was used for all non-Windows systems; now it is only used on macOS, the BSDs, and Illumos because those platforms fail to compile without it. There is no security bug being fixed here.
No security action needed. Treat as a normal build-compatibility fix.
Security signals we found
No security-relevant behavioral change
Build/portability fix only
No change to randomness collection logic
No memory safety, cryptographic, or input validation changes
Evidence from the diff
The commit changes the preprocessor guard around extern char** environ; in src/randomenv.cpp from #ifndef WIN32 to a whitelist of __APPLE__, __FreeBSD__, __NetBSD__, __OpenBSD__, and __illumos__. On Linux, environ is already provided via <unistd.h> (included earlier), so the redundant extern caused no functional change. The patch simply avoids compilation failures on platforms where the explicit extern is required and is purely a portability/build correction.
Changed components
src/randomenv.cppInspect captured patch +6 / −2
diff --git a/src/randomenv.cpp b/src/randomenv.cpp
index 2d32e50c..3aff81d1 100644
--- a/src/randomenv.cpp
+++ b/src/randomenv.cpp
@@ -57,8 +57,12 @@
#include <sys/auxv.h>
#endif
-#ifndef WIN32
-extern char** environ; // NOLINT(readability-redundant-declaration): Necessary on some platforms
+#if defined(__APPLE__) || \
+ defined(__FreeBSD__) || \
+ defined(__NetBSD__) || \
+ defined(__OpenBSD__) || \
+ defined(__illumos__)
+extern char** environ; // NOLINT(readability-redundant-declaration): Necessary on the above platforms
#endif
namespace {
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.