@@ -21,7 +21,6 @@ namespace node {
21
21
22
22
using v8::Array;
23
23
using v8::ArrayBufferView;
24
- using v8::Boolean ;
25
24
using v8::Context;
26
25
using v8::DontDelete;
27
26
using v8::Exception;
@@ -551,7 +550,9 @@ void SecureContext::SetEngineKey(const FunctionCallbackInfo<Value>& args) {
551
550
const Utf8Value engine_id (env->isolate (), args[1 ]);
552
551
EnginePointer engine = LoadEngineById (*engine_id, &errors);
553
552
if (!engine) {
554
- env->isolate ()->ThrowException (errors.ToException (env).ToLocalChecked ());
553
+ Local<Value> exception ;
554
+ if (errors.ToException (env).ToLocal (&exception ))
555
+ env->isolate ()->ThrowException (exception );
555
556
return ;
556
557
}
557
558
@@ -1061,7 +1062,9 @@ void SecureContext::SetClientCertEngine(
1061
1062
const node::Utf8Value engine_id (env->isolate (), args[0 ]);
1062
1063
EnginePointer engine = LoadEngineById (*engine_id, &errors);
1063
1064
if (!engine) {
1064
- env->isolate ()->ThrowException (errors.ToException (env).ToLocalChecked ());
1065
+ Local<Value> exception ;
1066
+ if (errors.ToException (env).ToLocal (&exception ))
1067
+ env->isolate ()->ThrowException (exception );
1065
1068
return ;
1066
1069
}
1067
1070
@@ -1079,7 +1082,10 @@ void SecureContext::GetTicketKeys(const FunctionCallbackInfo<Value>& args) {
1079
1082
SecureContext* wrap;
1080
1083
ASSIGN_OR_RETURN_UNWRAP (&wrap, args.Holder ());
1081
1084
1082
- Local<Object> buff = Buffer::New (wrap->env (), 48 ).ToLocalChecked ();
1085
+ Local<Object> buff;
1086
+ if (!Buffer::New (wrap->env (), 48 ).ToLocal (&buff))
1087
+ return ;
1088
+
1083
1089
memcpy (Buffer::Data (buff), wrap->ticket_key_name_ , 16 );
1084
1090
memcpy (Buffer::Data (buff) + 16 , wrap->ticket_key_hmac_ , 16 );
1085
1091
memcpy (Buffer::Data (buff) + 32 , wrap->ticket_key_aes_ , 16 );
@@ -1143,45 +1149,59 @@ int SecureContext::TicketKeyCallback(SSL* ssl,
1143
1149
HandleScope handle_scope (env->isolate ());
1144
1150
Context::Scope context_scope (env->context ());
1145
1151
1146
- Local<Value> argv[] = {
1147
- Buffer::Copy (env,
1148
- reinterpret_cast <char *>(name),
1149
- kTicketPartSize ).ToLocalChecked (),
1150
- Buffer::Copy (env,
1151
- reinterpret_cast <char *>(iv),
1152
- kTicketPartSize ).ToLocalChecked (),
1153
- Boolean::New (env->isolate (), enc != 0 )
1154
- };
1155
-
1156
- Local<Value> ret = node::MakeCallback (env->isolate (),
1157
- sc->object (),
1158
- env->ticketkeycallback_string (),
1159
- arraysize (argv),
1160
- argv,
1161
- {0 , 0 }).ToLocalChecked ();
1152
+ Local<Value> argv[3 ];
1153
+
1154
+ if (!Buffer::Copy (
1155
+ env,
1156
+ reinterpret_cast <char *>(name),
1157
+ kTicketPartSize ).ToLocal (&argv[0 ]) ||
1158
+ !Buffer::Copy (
1159
+ env,
1160
+ reinterpret_cast <char *>(iv),
1161
+ kTicketPartSize ).ToLocal (&argv[1 ])) {
1162
+ return -1 ;
1163
+ }
1164
+
1165
+ argv[2 ] = env != 0 ? v8::True (env->isolate ()) : v8::False (env->isolate ());
1166
+
1167
+ Local<Value> ret;
1168
+ if (!node::MakeCallback (
1169
+ env->isolate (),
1170
+ sc->object (),
1171
+ env->ticketkeycallback_string (),
1172
+ arraysize (argv),
1173
+ argv,
1174
+ {0 , 0 }).ToLocal (&ret) ||
1175
+ !ret->IsArray ()) {
1176
+ return -1 ;
1177
+ }
1162
1178
Local<Array> arr = ret.As <Array>();
1163
1179
1164
- int r =
1165
- arr->Get (env->context (),
1166
- kTicketKeyReturnIndex ).ToLocalChecked ()
1167
- ->Int32Value (env->context ()).FromJust ();
1180
+ Local<Value> val;
1181
+ if (!arr->Get (env->context (), kTicketKeyReturnIndex ).ToLocal (&val) ||
1182
+ !val->IsInt32 ()) {
1183
+ return -1 ;
1184
+ }
1185
+
1186
+ int r = val.As <Int32>()->Value ();
1168
1187
if (r < 0 )
1169
1188
return r;
1170
1189
1171
- Local<Value> hmac = arr->Get (env->context (),
1172
- kTicketKeyHMACIndex ).ToLocalChecked ();
1173
- Local<Value> aes = arr->Get (env->context (),
1174
- kTicketKeyAESIndex ).ToLocalChecked ();
1175
- if (Buffer::Length (aes) != kTicketPartSize )
1190
+ Local<Value> hmac;
1191
+ Local<Value> aes;
1192
+
1193
+ if (!arr->Get (env->context (), kTicketKeyHMACIndex ).ToLocal (&hmac) ||
1194
+ !arr->Get (env->context (), kTicketKeyAESIndex ).ToLocal (&aes) ||
1195
+ Buffer::Length (aes) != kTicketPartSize ) {
1176
1196
return -1 ;
1197
+ }
1177
1198
1178
1199
if (enc) {
1179
- Local<Value> name_val = arr->Get (env->context (),
1180
- kTicketKeyNameIndex ).ToLocalChecked ();
1181
- Local<Value> iv_val = arr->Get (env->context (),
1182
- kTicketKeyIVIndex ).ToLocalChecked ();
1183
-
1184
- if (Buffer::Length (name_val) != kTicketPartSize ||
1200
+ Local<Value> name_val;
1201
+ Local<Value> iv_val;
1202
+ if (!arr->Get (env->context (), kTicketKeyNameIndex ).ToLocal (&name_val) ||
1203
+ !arr->Get (env->context (), kTicketKeyIVIndex ).ToLocal (&iv_val) ||
1204
+ Buffer::Length (name_val) != kTicketPartSize ||
1185
1205
Buffer::Length (iv_val) != kTicketPartSize ) {
1186
1206
return -1 ;
1187
1207
}
@@ -1272,7 +1292,9 @@ void SecureContext::GetCertificate(const FunctionCallbackInfo<Value>& args) {
1272
1292
return args.GetReturnValue ().SetNull ();
1273
1293
1274
1294
int size = i2d_X509 (cert, nullptr );
1275
- Local<Object> buff = Buffer::New (env, size).ToLocalChecked ();
1295
+ Local<Object> buff;
1296
+ if (!Buffer::New (env, size).ToLocal (&buff))
1297
+ return ;
1276
1298
unsigned char * serialized = reinterpret_cast <unsigned char *>(
1277
1299
Buffer::Data (buff));
1278
1300
i2d_X509 (cert, &serialized);
0 commit comments