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 6aec92f

Browse filesBrowse files
tniessenaddaleax
authored andcommitted
src: gracefully handle errors in GetX509NameObject
PR-URL: #41490 Co-authored-by: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 5129b7c commit 6aec92f
Copy full SHA for 6aec92f

File tree

Expand file treeCollapse file tree

1 file changed

+16
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-7
lines changed
Open diff view settings
Collapse file

‎src/crypto/crypto_common.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_common.cc
+16-7Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,17 +1082,26 @@ static MaybeLocal<Value> GetX509NameObject(Environment* env, X509* cert) {
10821082
// change here without breaking things. Note that this creates nested data
10831083
// structures, yet still does not allow representing Distinguished Names
10841084
// accurately.
1085-
if (result->HasOwnProperty(env->context(), v8_name).ToChecked()) {
1086-
Local<Value> accum =
1087-
result->Get(env->context(), v8_name).ToLocalChecked();
1085+
bool multiple;
1086+
if (!result->HasOwnProperty(env->context(), v8_name).To(&multiple)) {
1087+
return MaybeLocal<Value>();
1088+
} else if (multiple) {
1089+
Local<Value> accum;
1090+
if (!result->Get(env->context(), v8_name).ToLocal(&accum)) {
1091+
return MaybeLocal<Value>();
1092+
}
10881093
if (!accum->IsArray()) {
10891094
accum = Array::New(env->isolate(), &accum, 1);
1090-
result->Set(env->context(), v8_name, accum).Check();
1095+
if (result->Set(env->context(), v8_name, accum).IsNothing()) {
1096+
return MaybeLocal<Value>();
1097+
}
10911098
}
10921099
Local<Array> array = accum.As<Array>();
1093-
array->Set(env->context(), array->Length(), v8_value).Check();
1094-
} else {
1095-
result->Set(env->context(), v8_name, v8_value).Check();
1100+
if (array->Set(env->context(), array->Length(), v8_value).IsNothing()) {
1101+
return MaybeLocal<Value>();
1102+
}
1103+
} else if (result->Set(env->context(), v8_name, v8_value).IsNothing()) {
1104+
return MaybeLocal<Value>();
10961105
}
10971106
}
10981107

0 commit comments

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