Skip to content

Fix cred_init() NULL-check (test the credkey result, not the function symbol)#107

Merged
mgrossmann merged 1 commit into
mainfrom
issue-106-credinit-nullcheck
Jul 5, 2026
Merged

Fix cred_init() NULL-check (test the credkey result, not the function symbol)#107
mgrossmann merged 1 commit into
mainfrom
issue-106-credinit-nullcheck

Conversation

@mgrossmann

Copy link
Copy Markdown
Contributor

cred_init() stored credkey()'s WSA pointer in key, then NULL-checked the function symbol credkey (its address is never NULL) instead of key — the guard was dead code (this is the credinit.c:8: warning: the address of 'credkey' will always evaluate as 'true').

If credkey() returns NULL (WSA allocation for the Blowfish key failed at init), cred_init() fell through and passed a NULL key to blowfish_key_setup() → NULL deref. The "unable to allocate WSA for BLOWFISH_KEY" message confirms the check was meant to test key.

One-line fix: if (!credkey)if (!key).

Verified: make modules compiles credentials/src/credinit.c warning-free; all 6 modules link.

Fixes #106

cred_init() stored credkey()'s WSA pointer in `key` but then checked the
function symbol `credkey` (whose address is never NULL) instead of `key`, so
the guard was dead code. A failed WSA allocation (credkey() == NULL) fell
through and handed a NULL key to blowfish_key_setup() -> NULL deref at init.
Check `key` so the failure returns -1 cleanly, as the message intends.

Fixes #106
@mgrossmann
mgrossmann merged commit 34c6e94 into main Jul 5, 2026
1 check passed
@mgrossmann
mgrossmann deleted the issue-106-credinit-nullcheck branch July 5, 2026 10:58
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.

cred_init() NULL-checks the credkey function symbol instead of its result

1 participant