| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -597,7 +597,6 @@ function openAsBlob(path, options = kEmptyObject) { | |||
| 597 | 597 | */ | |
| 598 | 598 | function read(fd, buffer, offsetOrOptions, length, position, callback) { | |
| 599 | 599 | fd = getValidatedFd(fd); | |
| 600 | - | ||
| 601 | 600 | let offset = offsetOrOptions; | |
| 602 | 601 | let params = null; | |
| 603 | 602 | if (arguments.length <= 4) { | |
@@ -689,8 +688,6 @@ ObjectDefineProperty(read, kCustomPromisifyArgsSymbol, | |||
| 689 | 688 | * @returns {number} | |
| 690 | 689 | */ | |
| 691 | 690 | function readSync(fd, buffer, offsetOrOptions, length, position) { | |
| 692 | - fd = getValidatedFd(fd); | ||
| 693 | - | ||
| 694 | 691 | validateBuffer(buffer); | |
| 695 | 692 | ||
| 696 | 693 | let offset = offsetOrOptions; | |
@@ -779,7 +776,6 @@ ObjectDefineProperty(readv, kCustomPromisifyArgsSymbol, | |||
| 779 | 776 | * @returns {number} | |
| 780 | 777 | */ | |
| 781 | 778 | function readvSync(fd, buffers, position) { | |
| 782 | - fd = getValidatedFd(fd); | ||
| 783 | 779 | validateBufferArray(buffers); | |
| 784 | 780 | ||
| 785 | 781 | if (typeof position !== 'number') | |
@@ -809,7 +805,6 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) { | |||
| 809 | 805 | } | |
| 810 | 806 | ||
| 811 | 807 | fd = getValidatedFd(fd); | |
| 812 | - | ||
| 813 | 808 | let offset = offsetOrOptions; | |
| 814 | 809 | if (isArrayBufferView(buffer)) { | |
| 815 | 810 | callback ||= position || length || offset; | |
@@ -880,7 +875,6 @@ ObjectDefineProperty(write, kCustomPromisifyArgsSymbol, | |||
| 880 | 875 | * @returns {number} | |
| 881 | 876 | */ | |
| 882 | 877 | function writeSync(fd, buffer, offsetOrOptions, length, position) { | |
| 883 | - fd = getValidatedFd(fd); | ||
| 884 | 878 | const ctx = {}; | |
| 885 | 879 | let result; | |
| 886 | 880 | ||
@@ -970,7 +964,6 @@ ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, { | |||
| 970 | 964 | * @returns {number} | |
| 971 | 965 | */ | |
| 972 | 966 | function writevSync(fd, buffers, position) { | |
| 973 | - fd = getValidatedFd(fd); | ||
| 974 | 967 | validateBufferArray(buffers); | |
| 975 | 968 | ||
| 976 | 969 | if (buffers.length === 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2314,8 +2314,10 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 2314 | 2314 | const int argc = args.Length(); | |
| 2315 | 2315 | CHECK_GE(argc, 4); | |
| 2316 | 2316 | ||
| 2317 | - CHECK(args[0]->IsInt32()); | ||
| 2318 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2317 | + int fd; | ||
| 2318 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2319 | + return; | ||
| 2320 | + } | ||
| 2319 | 2321 | ||
| 2320 | 2322 | CHECK(Buffer::HasInstance(args[1])); | |
| 2321 | 2323 | Local<Object> buffer_obj = args[1].As<Object>(); | |
@@ -2381,8 +2383,10 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) { | |||
| 2381 | 2383 | const int argc = args.Length(); | |
| 2382 | 2384 | CHECK_GE(argc, 3); | |
| 2383 | 2385 | ||
| 2384 | - CHECK(args[0]->IsInt32()); | ||
| 2385 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2386 | + int fd; | ||
| 2387 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2388 | + return; | ||
| 2389 | + } | ||
| 2386 | 2390 | ||
| 2387 | 2391 | CHECK(args[1]->IsArray()); | |
| 2388 | 2392 | Local<Array> chunks = args[1].As<Array>(); | |
@@ -2441,8 +2445,10 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) { | |||
| 2441 | 2445 | ||
| 2442 | 2446 | const int argc = args.Length(); | |
| 2443 | 2447 | CHECK_GE(argc, 4); | |
| 2444 | - CHECK(args[0]->IsInt32()); | ||
| 2445 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2448 | + int fd; | ||
| 2449 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2450 | + return; | ||
| 2451 | + } | ||
| 2446 | 2452 | ||
| 2447 | 2453 | const int64_t pos = GetOffset(args[2]); | |
| 2448 | 2454 | ||
@@ -2634,8 +2640,10 @@ static void Read(const FunctionCallbackInfo<Value>& args) { | |||
| 2634 | 2640 | const int argc = args.Length(); | |
| 2635 | 2641 | CHECK_GE(argc, 5); | |
| 2636 | 2642 | ||
| 2637 | - CHECK(args[0]->IsInt32()); | ||
| 2638 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2643 | + int fd; | ||
| 2644 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2645 | + return; | ||
| 2646 | + } | ||
| 2639 | 2647 | ||
| 2640 | 2648 | CHECK(Buffer::HasInstance(args[1])); | |
| 2641 | 2649 | Local<Object> buffer_obj = args[1].As<Object>(); | |
@@ -2765,8 +2773,10 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) { | |||
| 2765 | 2773 | const int argc = args.Length(); | |
| 2766 | 2774 | CHECK_GE(argc, 3); | |
| 2767 | 2775 | ||
| 2768 | - CHECK(args[0]->IsInt32()); | ||
| 2769 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2776 | + int fd; | ||
| 2777 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2778 | + return; | ||
| 2779 | + } | ||
| 2770 | 2780 | ||
| 2771 | 2781 | CHECK(args[1]->IsArray()); | |
| 2772 | 2782 | Local<Array> buffers = args[1].As<Array>(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments