dh: allow a zero-size export buffer - #477
Open
yosuke-wolfssl wants to merge 1 commit into
Open
Conversation
wolfSSL-Fenrir-bot
previously requested changes
Aug 26, 2026
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #477
Scan targets checked: wolfprovider-bugs, wolfprovider-src
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
- wp_dh_export() allocates the export data buffer only when the computed size is non-zero. - wp_dh_export() fails when the selection asks for parameters and wp_dh_has() reports no domain parameters on the key. - test_dh_export_named_group_params exports a parameter-only ffdhe2048 key through EVP_PKEY_todata() and requires the exported group name to be present, readable as a UTF-8 string, and equal to ffdhe2048; declared in test/unit.h and registered in test/unit.c. Issue: F-11557
yosuke-wolfssl
force-pushed
the
fix/f_11557
branch
from
August 27, 2026 00:57
fafa7a2 to
2c71ae6
Compare
yosuke-wolfssl
commented
Aug 27, 2026
yosuke-wolfssl
commented
Aug 27, 2026
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #477
Scan targets checked: wolfprovider-bugs, wolfprovider-src
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
wolfSSL-Fenrir-bot
dismissed
their stale review
August 27, 2026 01:13
Fenrir's latest completed scan found no issues; clearing the prior automated change request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
wp_dh_export()computes a single allocation covering both the group data and the key pair, then requiresOPENSSL_secure_malloc()to return non-NULL before it exports anything. For a parameter-only named-group key, both contributions are zero:wp_dh_export_group_alloc_size()returns 0 because a named group is exported as a string pointer with no backing buffer, andwp_dh_export_keypair_alloc_size()returns 0 when there are no public or private bytes.OPENSSL_secure_malloc(0)returns NULL, so a key that needed no buffer at all fails to export.Reachable through
EVP_PKEY_todata()and through any cross-provider export of DH domain parameters. Closes f-11557.Fix (
src/wp_dh_kmgmt.c)Allocate only when the computed size is non-zero:
datastays NULL on that path and is never dereferenced:wp_dh_export_group()touches it only in its explicit-parameters branch,wp_dh_export_keypair()is guarded bypubSz > 0/privSz > 0, andOPENSSL_secure_clear_free()returns early on a null pointer.Tests
test_dh_export_named_group_paramsimports anffdhe2048parameter-only key viaEVP_PKEY_fromdata(), exports it withEVP_PKEY_todata(), and requires a group name in the result — so it fails on a silently empty export as well as on the error return.Verification
-Werror; no new compiler warnings.Export of parameter-only named group key failed; it passes with the guard in place.