Skip to content

Fix GetLength return value check in ASN1_INTEGER functions#10109

Merged
douzzer merged 1 commit intowolfSSL:masterfrom
julek-wolfssl:openvpn-master
Mar 31, 2026
Merged

Fix GetLength return value check in ASN1_INTEGER functions#10109
douzzer merged 1 commit intowolfSSL:masterfrom
julek-wolfssl:openvpn-master

Conversation

@julek-wolfssl
Copy link
Copy Markdown
Member

Change GetLength() return check from > 0 to >= 0 in wolfSSL_ASN1_INTEGER_get_length
and wolfSSL_ASN1_INTEGER_get0_data. GetLength returns the decoded length (≥ 0) on
success and negative error codes on failure, so checking > 0 incorrectly excluded
zero-length values, making the DER-stripping logic dead code.

Change GetLength() return check from > 0 to >= 0 in wolfSSL_ASN1_INTEGER_get_length
and wolfSSL_ASN1_INTEGER_get0_data. GetLength returns the decoded length (≥ 0) on
success and negative error codes on failure, so checking > 0 incorrectly excluded
zero-length values, making the DER-stripping logic dead code.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes OpenSSL-compat ASN.1 INTEGER helpers in src/ssl_asn1.c to correctly treat GetLength() returning 0 as a successful decode (rather than an error), which allows DER header stripping to work for zero-length values.

Changes:

  • Update wolfSSL_ASN1_INTEGER_get_length() to accept GetLength() >= 0 so a decoded length of 0 is handled as success.
  • Update wolfSSL_ASN1_INTEGER_get0_data() similarly so the returned pointer skips the DER header even when the value length is 0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ssl_asn1.c
@julek-wolfssl
Copy link
Copy Markdown
Member Author

retest this please ocsp-stapling failure

@douzzer douzzer merged commit ef3ba49 into wolfSSL:master Mar 31, 2026
504 of 506 checks passed
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