Fix read length in ASN1_STRING_print_ex/to_UTF8. Refactor freeing logic in wolfSSL_X509_get0_extensions. Only read GENERAL_NAME types with strings in wolfSSL_X509V3_EXT_print. Properly handle NULLs inside of DNs in X509_NAME_oneline. - #11627
Open
kareem-wolfssl wants to merge 4 commits into
Open
kareem-wolfssl wants to merge 4 commits into
kareem-wolfssl wants to merge 4 commits into
Conversation
Thanks to Anthropic for the report.
…ing the extension stack unless it is NULL. Allow non critical extensions and extensions with zero-length OCTET STRING to match the core DER parser behavior. Thanks to Anthropic for the report.
Thanks to Anthropic for the report.
Thanks to Anthropic for the report.
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The NUL escape remains ambiguous with literal \x00 input, allowing distinct names to compare equal.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Improves OpenSSL compatibility and safety for ASN.1 strings, X.509 extensions, general names, and embedded NULs in distinguished names.
Changes:
- Uses explicit ASN.1 lengths and ensures UTF-8 output termination.
- Stabilizes cached extension stacks and safely handles GENERAL_NAME variants.
- Escapes embedded NULs in one-line X.509 names and adds regression tests.
| File | Description |
|---|---|
wolfssl/openssl/x509.h |
Aligns one-line name flags with OpenSSL. |
src/x509.c |
Updates extension caching, parsing, printing, and DN rendering. |
src/ssl_asn1.c |
Fixes length-based ASN.1 copying and printing. |
tests/api/test_ossl_asn1.c |
Updates escaped-string length coverage. |
tests/api/test_ossl_x509_ext.c |
Tests extension stability and GENERAL_NAME safety. |
tests/api/test_ossl_x509_ext.h |
Registers the extension stability test. |
tests/api/test_ossl_x509_name.c |
Tests embedded-NUL distinguished names. |
tests/api/test_ossl_x509_name.h |
Registers the embedded-NUL test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+14741
to
+14751
| int need = (val[i] == '\0') ? NAME_NUL_ESC_SZ : 1; | ||
|
|
||
| if (need > INT_MAX - sz) | ||
| return BUFFER_E; | ||
| if (out != NULL) { | ||
| if (need > outSz - sz) | ||
| return BUFFER_E; | ||
| if (need == 1) | ||
| out[sz] = (char)val[i]; | ||
| else | ||
| XMEMCPY(out + sz, "\\x00", NAME_NUL_ESC_SZ); |
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.

Description
Partially fixes zd#22448
Testing
Built in + added tests, reproducers
Checklist