Skip to content

random: include unistd.h wherever getpid() is used - #11918

Open
stenslae wants to merge 1 commit into
wolfSSL:masterfrom
stenslae:fix/rng-getpid-unistd
Open

stenslae wants to merge 1 commit into
wolfSSL:masterfrom
stenslae:fix/rng-getpid-unistd

Conversation

@stenslae

Copy link
Copy Markdown
Member

Description

Only the default seed-source branch included unistd.h, so --enable-leanpsk (NO_DEV_RANDOM) called getpid() undeclared, which GCC 14 rejects.

  • Included <unistd.h> whenever defined(HAVE_GETPID) && !defined(WOLFSSL_NO_GETPID).
  • Added a "leanpsk" CI check compiling with --enable-leanpsk and -Werror=implicit-function-declaration -Wno-error=cpp to prevent regression.

Upstream repro:

    ./autogen.sh
    ./configure --enable-leanpsk
    EXTRA_CFLAGS="-Werror=implicit-function-declaration -Wno-error=cpp"

Testing

  • Tested building with --enable-leanpsk on GCC 14.
  • Ran ./wolfcrypt/test/testwolfcrypt.
  • Verified new leanpsk entry in .github/configs/os-check-linux.json.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Only the default seed-source branch included it, so --enable-leanpsk
(NO_DEV_RANDOM) called getpid() undeclared, which GCC 14 rejects.
@stenslae stenslae self-assigned this Oct 28, 2026
Copilot AI balanced review requested due to automatic review settings October 28, 2026 22:03
@stenslae

Copy link
Copy Markdown
Member Author

@claude review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the lean PSK getpid() header fix and added regression configuration.

No open issues 🎉

What changed in this PR

Fixes an undeclared getpid() call in lean PSK builds by making its header available independently of the selected random seed source.

Changes:

  • Includes <unistd.h> when HAVE_GETPID is defined and WOLFSSL_NO_GETPID is not.
  • Adds a lean PSK CI configuration that rejects implicit function declarations and runs the wolfCrypt self-test.
File Description
wolfcrypt/​src/​random.c Adds a conditional <unistd.h> include for getpid().
.github/​configs/​os-check-linux.json Adds lean PSK regression coverage with targeted compiler flags.

Review effort: Balanced

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #11918

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Not reviewed (no scan target covers them): .github/configs/os-check-linux.json
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This is a small, correctly guarded include fix, and the new CI entry should catch it if it regresses.

What was reviewed:

  • The new <unistd.h> include in wolfcrypt/src/random.c uses the same HAVE_GETPID && !WOLFSSL_NO_GETPID guard as every getpid()/pid_t use in the file, so builds without getpid are unaffected.
  • Non-POSIX ports: HAVE_GETPID is set only when configure or CMake finds getpid (CMake probes it through unistd.h, so MSVC never sets it), and settings.h forces WOLFSSL_NO_GETPID for its bare-metal profiles.
  • The leanpsk entry is valid JSON, uses keys parallel-make-check.py accepts, and its extra_cflags match the workflow's global set minus -pedantic/-Wno-overlength-strings.
Extended reasoning...

The change adds one guarded #include <unistd.h> to wolfcrypt/src/random.c and one new CI config entry in .github/configs/os-check-linux.json. It does not change any RNG, seeding or crypto logic. It only makes the existing getpid() calls declared under NO_DEV_RANDOM and other seed branches that never included unistd.h. The include's guard matches the guard on every getpid use, and HAVE_GETPID is only defined when the build system has found getpid, so non-POSIX targets are unaffected. No CODEOWNERS file covers these paths, and the PR has no outstanding reviewer objections.

@stenslae stenslae assigned wolfSSL-Bot and unassigned stenslae Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants