-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixed encode policy oid #11019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fixed encode policy oid #11019
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1358,7 +1358,7 @@ static int wolfssl_x509_add_custom_ext(WOLFSSL_X509 *x509, | |
|
|
||
| if (err == 0) { | ||
| XMEMCPY(val, ext->value.data, ext->value.length); | ||
| if (wolfSSL_OBJ_obj2txt(oid, MAX_OID_STRING_SZ, ext->obj, 1) < 0) { | ||
| if (wolfSSL_OBJ_obj2txt(oid, MAX_OID_STRING_SZ, ext->obj, 1) <= 0) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ [Info] Changed obj2txt failure guard in wolfssl_x509_add_custom_ext has no test coverage · Missing edge-case coverage on a function the PR also changed The guard was widened from Fix: Add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ [Info] Tightened wolfssl_x509_add_custom_ext return check has no test coverage · Missing edge-case coverage on a function the PR also changed The Fix: Add a |
||
| err = 1; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc comment states "String is of the form ... and is always NUL terminated. Truncated when the buffer is too small." The PR tightens
wc_DecodePolicyOID's length checks fromw > outSz - outIdxtow >= outSz - outIdxand adds a bound check on the firstXSNPRINTFthat had none, so the exact-fit case that previously produced a silently truncated (and therefore wrong) OID string now returnsBUFFER_E, which this function maps toWOLFSSL_FAILURE. The stricter behavior is the right call - a silently shortened OID string is worse than an error, and the missing first-XSNPRINTFcheck was an out-of-boundsout[outIdx] = 0write when the first identifier alone overflowed the caller's buffer - but the comment now describes behavior the code no longer has, and it diverges from OpenSSL'sOBJ_obj2txt, which truncates and returns the length that would have been needed.Code:
Recommendation: Update the comment to say the call fails rather than truncates on a short buffer, and note the OpenSSL-compat divergence if it matters for callers of
wolfSSL_OBJ_obj2txt(buf, small, obj, 1).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the doc comment to explicitly state that the function will fail and return BUFFER_E when the buffer is too small. I also added a note regarding the divergence from OpenSSL's OBJ_obj2txt behavior.