| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c32d557 commit 9565029
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -771,7 +771,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | |||
| 771 | 771 | } else if (isUint8Array(val)) { | |
| 772 | 772 | return indexOfBuffer(buffer, val, byteOffset, encoding, dir); | |
| 773 | 773 | } else if (typeof val === 'number') { | |
| 774 | - return indexOfNumber(buffer, val, byteOffset, dir); | ||
| 774 | + return indexOfNumber(buffer, val >>> 0, byteOffset, dir); | ||
| 775 | 775 | } | |
| 776 | 776 | ||
| 777 | 777 | throw new ERR_INVALID_ARG_TYPE( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ using v8::MaybeLocal; | |||
| 21 | 21 | using v8::NewStringType; | |
| 22 | 22 | using v8::Object; | |
| 23 | 23 | using v8::String; | |
| 24 | + using v8::Uint32; | ||
| 24 | 25 | using v8::Value; | |
| 25 | 26 | ||
| 26 | 27 | using v8_inspector::StringBuffer; | |
@@ -241,7 +242,7 @@ void Open(const FunctionCallbackInfo<Value>& args) { | |||
| 241 | 242 | bool wait_for_connect = false; | |
| 242 | 243 | ||
| 243 | 244 | if (args.Length() > 0 && args[0]->IsUint32()) { | |
| 244 | - uint32_t port = args[0]->Uint32Value(); | ||
| 245 | + uint32_t port = args[0].As<Uint32>()->Value(); | ||
| 245 | 246 | agent->options()->host_port.port = port; | |
| 246 | 247 | } | |
| 247 | 248 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,6 +83,7 @@ using v8::Maybe; | |||
| 83 | 83 | using v8::MaybeLocal; | |
| 84 | 84 | using v8::Object; | |
| 85 | 85 | using v8::String; | |
| 86 | + using v8::Uint32; | ||
| 86 | 87 | using v8::Uint32Array; | |
| 87 | 88 | using v8::Uint8Array; | |
| 88 | 89 | using v8::Value; | |
@@ -565,12 +566,15 @@ void Copy(const FunctionCallbackInfo<Value> &args) { | |||
| 565 | 566 | ||
| 566 | 567 | void Fill(const FunctionCallbackInfo<Value>& args) { | |
| 567 | 568 | Environment* env = Environment::GetCurrent(args); | |
| 569 | + Local<Context> ctx = env->context(); | ||
| 568 | 570 | ||
| 569 | 571 | THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]); | |
| 570 | 572 | SPREAD_BUFFER_ARG(args[0], ts_obj); | |
| 571 | 573 | ||
| 572 | - size_t start = args[2]->Uint32Value(); | ||
| 573 | - size_t end = args[3]->Uint32Value(); | ||
| 574 | + uint32_t start; | ||
| 575 | + if (!args[2]->Uint32Value(ctx).To(&start)) return; | ||
| 576 | + uint32_t end; | ||
| 577 | + if (!args[3]->Uint32Value(ctx).To(&end)) return; | ||
| 574 | 578 | size_t fill_length = end - start; | |
| 575 | 579 | Local<String> str_obj; | |
| 576 | 580 | size_t str_length; | |
@@ -590,7 +594,9 @@ void Fill(const FunctionCallbackInfo<Value>& args) { | |||
| 590 | 594 | ||
| 591 | 595 | // Then coerce everything that's not a string. | |
| 592 | 596 | if (!args[1]->IsString()) { | |
| 593 | - int value = args[1]->Uint32Value() & 255; | ||
| 597 | + uint32_t val; | ||
| 598 | + if (!args[1]->Uint32Value(ctx).To(&val)) return; | ||
| 599 | + int value = val & 255; | ||
| 594 | 600 | memset(ts_obj_data + start, value, fill_length); | |
| 595 | 601 | return; | |
| 596 | 602 | } | |
@@ -1000,14 +1006,14 @@ void IndexOfBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 1000 | 1006 | } | |
| 1001 | 1007 | ||
| 1002 | 1008 | void IndexOfNumber(const FunctionCallbackInfo<Value>& args) { | |
| 1003 | - CHECK(args[1]->IsNumber()); | ||
| 1009 | + CHECK(args[1]->IsUint32()); | ||
| 1004 | 1010 | CHECK(args[2]->IsNumber()); | |
| 1005 | 1011 | CHECK(args[3]->IsBoolean()); | |
| 1006 | 1012 | ||
| 1007 | 1013 | THROW_AND_RETURN_UNLESS_BUFFER(Environment::GetCurrent(args), args[0]); | |
| 1008 | 1014 | SPREAD_BUFFER_ARG(args[0], ts_obj); | |
| 1009 | 1015 | ||
| 1010 | - uint32_t needle = args[1]->Uint32Value(); | ||
| 1016 | + uint32_t needle = args[1].As<Uint32>()->Value(); | ||
| 1011 | 1017 | int64_t offset_i64 = args[2]->IntegerValue(); | |
| 1012 | 1018 | bool is_forward = args[3]->IsTrue(); | |
| 1013 | 1019 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3885,7 +3885,8 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) { | |||
| 3885 | 3885 | char* buf = Buffer::Data(args[1]); | |
| 3886 | 3886 | ssize_t len = Buffer::Length(args[1]); | |
| 3887 | 3887 | ||
| 3888 | - int padding = args[2]->Uint32Value(); | ||
| 3888 | + uint32_t padding; | ||
| 3889 | + if (!args[2]->Uint32Value(env->context()).To(&padding)) return; | ||
| 3889 | 3890 | ||
| 3890 | 3891 | String::Utf8Value passphrase(args.GetIsolate(), args[3]); | |
| 3891 | 3892 | ||
@@ -4450,8 +4451,9 @@ void ECDH::GetPublicKey(const FunctionCallbackInfo<Value>& args) { | |||
| 4450 | 4451 | return env->ThrowError("Failed to get ECDH public key"); | |
| 4451 | 4452 | ||
| 4452 | 4453 | int size; | |
| 4453 | - point_conversion_form_t form = | ||
| 4454 | - static_cast<point_conversion_form_t>(args[0]->Uint32Value()); | ||
| 4454 | + CHECK(args[0]->IsUint32()); | ||
| 4455 | + uint32_t val = args[0].As<Uint32>()->Value(); | ||
| 4456 | + point_conversion_form_t form = static_cast<point_conversion_form_t>(val); | ||
| 4455 | 4457 | ||
| 4456 | 4458 | size = EC_POINT_point2oct(ecdh->group_, pub, form, nullptr, 0, nullptr); | |
| 4457 | 4459 | if (size == 0) | |
@@ -5066,8 +5068,9 @@ void ConvertKey(const FunctionCallbackInfo<Value>& args) { | |||
| 5066 | 5068 | if (pub == nullptr) | |
| 5067 | 5069 | return env->ThrowError("Failed to convert Buffer to EC_POINT"); | |
| 5068 | 5070 | ||
| 5069 | - point_conversion_form_t form = | ||
| 5070 | - static_cast<point_conversion_form_t>(args[2]->Uint32Value()); | ||
| 5071 | + CHECK(args[2]->IsUint32()); | ||
| 5072 | + uint32_t val = args[2].As<Uint32>()->Value(); | ||
| 5073 | + point_conversion_form_t form = static_cast<point_conversion_form_t>(val); | ||
| 5071 | 5074 | ||
| 5072 | 5075 | int size = EC_POINT_point2oct( | |
| 5073 | 5076 | group.get(), pub.get(), form, nullptr, 0, nullptr); | |
@@ -5166,7 +5169,8 @@ void InitCryptoOnce() { | |||
| 5166 | 5169 | void SetEngine(const FunctionCallbackInfo<Value>& args) { | |
| 5167 | 5170 | Environment* env = Environment::GetCurrent(args); | |
| 5168 | 5171 | CHECK(args.Length() >= 2 && args[0]->IsString()); | |
| 5169 | - unsigned int flags = args[1]->Uint32Value(); | ||
| 5172 | + uint32_t flags; | ||
| 5173 | + if (!args[1]->Uint32Value(env->context()).To(&flags)) return; | ||
| 5170 | 5174 | ||
| 5171 | 5175 | ClearErrorOnReturn clear_error_on_return; | |
| 5172 | 5176 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -819,9 +819,9 @@ static void GetStringWidth(const FunctionCallbackInfo<Value>& args) { | |||
| 819 | 819 | bool expand_emoji_sequence = args[2]->IsTrue(); | |
| 820 | 820 | ||
| 821 | 821 | if (args[0]->IsNumber()) { | |
| 822 | - args.GetReturnValue().Set( | ||
| 823 | - GetColumnWidth(args[0]->Uint32Value(), | ||
| 824 | - ambiguous_as_full_width)); | ||
| 822 | + uint32_t val; | ||
| 823 | + if (!args[0]->Uint32Value(env->context()).To(&val)) return; | ||
| 824 | + args.GetReturnValue().Set(GetColumnWidth(val, ambiguous_as_full_width)); | ||
| 825 | 825 | return; | |
| 826 | 826 | } | |
| 827 | 827 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -345,7 +345,7 @@ static const char* name_by_gid(gid_t gid) { | |||
| 345 | 345 | ||
| 346 | 346 | static uid_t uid_by_name(Isolate* isolate, Local<Value> value) { | |
| 347 | 347 | if (value->IsUint32()) { | |
| 348 | - return static_cast<uid_t>(value->Uint32Value()); | ||
| 348 | + return static_cast<uid_t>(value.As<Uint32>()->Value()); | ||
| 349 | 349 | } else { | |
| 350 | 350 | Utf8Value name(isolate, value); | |
| 351 | 351 | return uid_by_name(*name); | |
@@ -355,7 +355,7 @@ static uid_t uid_by_name(Isolate* isolate, Local<Value> value) { | |||
| 355 | 355 | ||
| 356 | 356 | static gid_t gid_by_name(Isolate* isolate, Local<Value> value) { | |
| 357 | 357 | if (value->IsUint32()) { | |
| 358 | - return static_cast<gid_t>(value->Uint32Value()); | ||
| 358 | + return static_cast<gid_t>(value.As<Uint32>()->Value()); | ||
| 359 | 359 | } else { | |
| 360 | 360 | Utf8Value name(isolate, value); | |
| 361 | 361 | return gid_by_name(*name); | |
@@ -534,7 +534,7 @@ void InitGroups(const FunctionCallbackInfo<Value>& args) { | |||
| 534 | 534 | char* user; | |
| 535 | 535 | ||
| 536 | 536 | if (args[0]->IsUint32()) { | |
| 537 | - user = name_by_uid(args[0]->Uint32Value()); | ||
| 537 | + user = name_by_uid(args[0].As<Uint32>()->Value()); | ||
| 538 | 538 | must_free = true; | |
| 539 | 539 | } else { | |
| 540 | 540 | user = *arg0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,6 +49,7 @@ using v8::Local; | |||
| 49 | 49 | using v8::Number; | |
| 50 | 50 | using v8::Object; | |
| 51 | 51 | using v8::String; | |
| 52 | + using v8::Uint32; | ||
| 52 | 53 | using v8::Uint32Array; | |
| 53 | 54 | using v8::Value; | |
| 54 | 55 | ||
@@ -155,7 +156,11 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { | |||
| 155 | 156 | ||
| 156 | 157 | CHECK_EQ(false, args[0]->IsUndefined() && "must provide flush value"); | |
| 157 | 158 | ||
| 158 | - unsigned int flush = args[0]->Uint32Value(); | ||
| 159 | + Environment* env = ctx->env(); | ||
| 160 | + Local<Context> context = env->context(); | ||
| 161 | + | ||
| 162 | + unsigned int flush; | ||
| 163 | + if (!args[0]->Uint32Value(context).To(&flush)) return; | ||
| 159 | 164 | ||
| 160 | 165 | if (flush != Z_NO_FLUSH && | |
| 161 | 166 | flush != Z_PARTIAL_FLUSH && | |
@@ -170,8 +175,7 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { | |||
| 170 | 175 | ||
| 171 | 176 | Bytef* in; | |
| 172 | 177 | Bytef* out; | |
| 173 | - size_t in_off, in_len, out_off, out_len; | ||
| 174 | - Environment* env = ctx->env(); | ||
| 178 | + uint32_t in_off, in_len, out_off, out_len; | ||
| 175 | 179 | ||
| 176 | 180 | if (args[1]->IsNull()) { | |
| 177 | 181 | // just a flush | |
@@ -181,18 +185,18 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { | |||
| 181 | 185 | } else { | |
| 182 | 186 | CHECK(Buffer::HasInstance(args[1])); | |
| 183 | 187 | Local<Object> in_buf; | |
| 184 | - in_buf = args[1]->ToObject(env->context()).ToLocalChecked(); | ||
| 185 | - in_off = args[2]->Uint32Value(); | ||
| 186 | - in_len = args[3]->Uint32Value(); | ||
| 188 | + in_buf = args[1]->ToObject(context).ToLocalChecked(); | ||
| 189 | + if (!args[2]->Uint32Value(context).To(&in_off)) return; | ||
| 190 | + if (!args[3]->Uint32Value(context).To(&in_len)) return; | ||
| 187 | 191 | ||
| 188 | 192 | CHECK(Buffer::IsWithinBounds(in_off, in_len, Buffer::Length(in_buf))); | |
| 189 | 193 | in = reinterpret_cast<Bytef *>(Buffer::Data(in_buf) + in_off); | |
| 190 | 194 | } | |
| 191 | 195 | ||
| 192 | 196 | CHECK(Buffer::HasInstance(args[4])); | |
| 193 | - Local<Object> out_buf = args[4]->ToObject(env->context()).ToLocalChecked(); | ||
| 194 | - out_off = args[5]->Uint32Value(); | ||
| 195 | - out_len = args[6]->Uint32Value(); | ||
| 197 | + Local<Object> out_buf = args[4]->ToObject(context).ToLocalChecked(); | ||
| 198 | + if (!args[5]->Uint32Value(context).To(&out_off)) return; | ||
| 199 | + if (!args[6]->Uint32Value(context).To(&out_len)) return; | ||
| 196 | 200 | CHECK(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf))); | |
| 197 | 201 | out = reinterpret_cast<Bytef *>(Buffer::Data(out_buf) + out_off); | |
| 198 | 202 | ||
@@ -438,32 +442,38 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { | |||
| 438 | 442 | ZCtx* ctx; | |
| 439 | 443 | ASSIGN_OR_RETURN_UNWRAP(&ctx, args.Holder()); | |
| 440 | 444 | ||
| 445 | + Local<Context> context = args.GetIsolate()->GetCurrentContext(); | ||
| 446 | + | ||
| 441 | 447 | // windowBits is special. On the compression side, 0 is an invalid value. | |
| 442 | 448 | // But on the decompression side, a value of 0 for windowBits tells zlib | |
| 443 | 449 | // to use the window size in the zlib header of the compressed stream. | |
| 444 | - int windowBits = args[0]->Uint32Value(); | ||
| 450 | + uint32_t windowBits; | ||
| 451 | + if (!args[0]->Uint32Value(context).To(&windowBits)) return; | ||
| 452 | + | ||
| 445 | 453 | if (!((windowBits == 0) && | |
| 446 | 454 | (ctx->mode_ == INFLATE || | |
| 447 | 455 | ctx->mode_ == GUNZIP || | |
| 448 | 456 | ctx->mode_ == UNZIP))) { | |
| 449 | - CHECK((windowBits >= Z_MIN_WINDOWBITS && | ||
| 450 | - windowBits <= Z_MAX_WINDOWBITS) && "invalid windowBits"); | ||
| 457 | + CHECK( | ||
| 458 | + (windowBits >= Z_MIN_WINDOWBITS && windowBits <= Z_MAX_WINDOWBITS) && | ||
| 459 | + "invalid windowBits"); | ||
| 451 | 460 | } | |
| 452 | 461 | ||
| 453 | 462 | int level = args[1]->Int32Value(); | |
| 454 | 463 | CHECK((level >= Z_MIN_LEVEL && level <= Z_MAX_LEVEL) && | |
| 455 | 464 | "invalid compression level"); | |
| 456 | 465 | ||
| 457 | - int memLevel = args[2]->Uint32Value(); | ||
| 466 | + uint32_t memLevel; | ||
| 467 | + if (!args[2]->Uint32Value(context).To(&memLevel)) return; | ||
| 458 | 468 | CHECK((memLevel >= Z_MIN_MEMLEVEL && memLevel <= Z_MAX_MEMLEVEL) && | |
| 459 | - "invalid memlevel"); | ||
| 460 | - | ||
| 461 | - int strategy = args[3]->Uint32Value(); | ||
| 462 | - CHECK((strategy == Z_FILTERED || | ||
| 463 | - strategy == Z_HUFFMAN_ONLY || | ||
| 464 | - strategy == Z_RLE || | ||
| 465 | - strategy == Z_FIXED || | ||
| 466 | - strategy == Z_DEFAULT_STRATEGY) && "invalid strategy"); | ||
| 469 | + "invalid memlevel"); | ||
| 470 | + | ||
| 471 | + uint32_t strategy; | ||
| 472 | + if (!args[3]->Uint32Value(context).To(&strategy)) return; | ||
| 473 | + CHECK((strategy == Z_FILTERED || strategy == Z_HUFFMAN_ONLY || | ||
| 474 | + strategy == Z_RLE || strategy == Z_FIXED || | ||
| 475 | + strategy == Z_DEFAULT_STRATEGY) && | ||
| 476 | + "invalid strategy"); | ||
| 467 | 477 | ||
| 468 | 478 | CHECK(args[4]->IsUint32Array()); | |
| 469 | 479 | Local<Uint32Array> array = args[4].As<Uint32Array>(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,6 +48,7 @@ using v8::Integer; | |||
| 48 | 48 | using v8::Local; | |
| 49 | 49 | using v8::Object; | |
| 50 | 50 | using v8::String; | |
| 51 | + using v8::Uint32; | ||
| 51 | 52 | using v8::Value; | |
| 52 | 53 | ||
| 53 | 54 | using AsyncHooks = Environment::AsyncHooks; | |
@@ -180,7 +181,7 @@ void TCPWrap::SetKeepAlive(const FunctionCallbackInfo<Value>& args) { | |||
| 180 | 181 | args.Holder(), | |
| 181 | 182 | args.GetReturnValue().Set(UV_EBADF)); | |
| 182 | 183 | int enable = args[0]->Int32Value(); | |
| 183 | - unsigned int delay = args[1]->Uint32Value(); | ||
| 184 | + unsigned int delay = args[1].As<Uint32>()->Value(); | ||
| 184 | 185 | int err = uv_tcp_keepalive(&wrap->handle_, enable, delay); | |
| 185 | 186 | args.GetReturnValue().Set(err); | |
| 186 | 187 | } | |
@@ -277,7 +278,7 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args) { | |||
| 277 | 278 | ||
| 278 | 279 | Local<Object> req_wrap_obj = args[0].As<Object>(); | |
| 279 | 280 | node::Utf8Value ip_address(env->isolate(), args[1]); | |
| 280 | - int port = args[2]->Uint32Value(); | ||
| 281 | + int port = args[2].As<Uint32>()->Value(); | ||
| 281 | 282 | ||
| 282 | 283 | sockaddr_in addr; | |
| 283 | 284 | int err = uv_ip4_addr(*ip_address, port, &addr); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,8 +179,11 @@ void UDPWrap::DoBind(const FunctionCallbackInfo<Value>& args, int family) { | |||
| 179 | 179 | CHECK_EQ(args.Length(), 3); | |
| 180 | 180 | ||
| 181 | 181 | node::Utf8Value address(args.GetIsolate(), args[0]); | |
| 182 | - const int port = args[1]->Uint32Value(); | ||
| 183 | - const int flags = args[2]->Uint32Value(); | ||
| 182 | + Local<Context> ctx = args.GetIsolate()->GetCurrentContext(); | ||
| 183 | + uint32_t port, flags; | ||
| 184 | + if (!args[1]->Uint32Value(ctx).To(&port) || | ||
| 185 | + !args[2]->Uint32Value(ctx).To(&flags)) | ||
| 186 | + return; | ||
| 184 | 187 | char addr[sizeof(sockaddr_in6)]; | |
| 185 | 188 | int err; | |
| 186 | 189 | ||
@@ -340,8 +343,8 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) { | |||
| 340 | 343 | Local<Array> chunks = args[1].As<Array>(); | |
| 341 | 344 | // it is faster to fetch the length of the | |
| 342 | 345 | // array in js-land | |
| 343 | - size_t count = args[2]->Uint32Value(); | ||
| 344 | - const unsigned short port = args[3]->Uint32Value(); | ||
| 346 | + size_t count = args[2].As<Uint32>()->Value(); | ||
| 347 | + const unsigned short port = args[3].As<Uint32>()->Value(); | ||
| 345 | 348 | node::Utf8Value address(env->isolate(), args[4]); | |
| 346 | 349 | const bool have_callback = args[5]->IsTrue(); | |
| 347 | 350 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments