Skip to content

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
wolfSSL:masterfrom
kareem-wolfssl:zd22448_x509

Conversation

@kareem-wolfssl

Copy link
Copy Markdown
Contributor

Description

Partially fixes zd#22448

Testing

Built in + added tests, reproducers

Checklist

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

…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.

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.

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 High severity

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 thread src/x509.c
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);
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.

2 participants