Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc6e0fc

Browse filesBrowse files
tniessenruyadorno
authored andcommitted
src: improve SPKAC::ExportChallenge()
Declare buf as an unsigned char to get rid of the reinterpret_cast and do not ignore the return value of ASN1_STRING_TO_UTF8. This also removes the need to call strlen() on the result. PR-URL: #44002 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent b7aaf3d commit cc6e0fc
Copy full SHA for cc6e0fc

File tree

Expand file treeCollapse file tree

1 file changed

+3
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-6
lines changed
Open diff view settings
Collapse file

‎src/crypto/crypto_spkac.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_spkac.cc
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,9 @@ ByteSource ExportChallenge(const ArrayBufferOrViewContents<char>& input) {
100100
if (!sp)
101101
return ByteSource();
102102

103-
char* buf = nullptr;
104-
ASN1_STRING_to_UTF8(
105-
reinterpret_cast<unsigned char**>(&buf),
106-
sp->spkac->challenge);
107-
108-
return ByteSource::Allocated(buf, strlen(buf));
103+
unsigned char* buf = nullptr;
104+
int buf_size = ASN1_STRING_to_UTF8(&buf, sp->spkac->challenge);
105+
return (buf_size >= 0) ? ByteSource::Allocated(buf, buf_size) : ByteSource();
109106
}
110107

111108
void ExportChallenge(const FunctionCallbackInfo<Value>& args) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.