| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -601,7 +601,6 @@ function openAsBlob(path, options = kEmptyObject) { | |||
| 601 | 601 | */ | |
| 602 | 602 | function read(fd, buffer, offsetOrOptions, length, position, callback) { | |
| 603 | 603 | fd = getValidatedFd(fd); | |
| 604 | - | ||
| 605 | 604 | let offset = offsetOrOptions; | |
| 606 | 605 | let params = null; | |
| 607 | 606 | if (arguments.length <= 4) { | |
@@ -693,8 +692,6 @@ ObjectDefineProperty(read, kCustomPromisifyArgsSymbol, | |||
| 693 | 692 | * @returns {number} | |
| 694 | 693 | */ | |
| 695 | 694 | function readSync(fd, buffer, offsetOrOptions, length, position) { | |
| 696 | - fd = getValidatedFd(fd); | ||
| 697 | - | ||
| 698 | 695 | validateBuffer(buffer); | |
| 699 | 696 | ||
| 700 | 697 | let offset = offsetOrOptions; | |
@@ -783,7 +780,6 @@ ObjectDefineProperty(readv, kCustomPromisifyArgsSymbol, | |||
| 783 | 780 | * @returns {number} | |
| 784 | 781 | */ | |
| 785 | 782 | function readvSync(fd, buffers, position) { | |
| 786 | - fd = getValidatedFd(fd); | ||
| 787 | 783 | validateBufferArray(buffers); | |
| 788 | 784 | ||
| 789 | 785 | if (typeof position !== 'number') | |
@@ -813,7 +809,6 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) { | |||
| 813 | 809 | } | |
| 814 | 810 | ||
| 815 | 811 | fd = getValidatedFd(fd); | |
| 816 | - | ||
| 817 | 812 | let offset = offsetOrOptions; | |
| 818 | 813 | if (isArrayBufferView(buffer)) { | |
| 819 | 814 | callback ||= position || length || offset; | |
@@ -884,7 +879,6 @@ ObjectDefineProperty(write, kCustomPromisifyArgsSymbol, | |||
| 884 | 879 | * @returns {number} | |
| 885 | 880 | */ | |
| 886 | 881 | function writeSync(fd, buffer, offsetOrOptions, length, position) { | |
| 887 | - fd = getValidatedFd(fd); | ||
| 888 | 882 | const ctx = {}; | |
| 889 | 883 | let result; | |
| 890 | 884 | ||
@@ -974,7 +968,6 @@ ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, { | |||
| 974 | 968 | * @returns {number} | |
| 975 | 969 | */ | |
| 976 | 970 | function writevSync(fd, buffers, position) { | |
| 977 | - fd = getValidatedFd(fd); | ||
| 978 | 971 | validateBufferArray(buffers); | |
| 979 | 972 | ||
| 980 | 973 | if (buffers.length === 0) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2305,8 +2305,10 @@ static void WriteBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 2305 | 2305 | const int argc = args.Length(); | |
| 2306 | 2306 | CHECK_GE(argc, 4); | |
| 2307 | 2307 | ||
| 2308 | - CHECK(args[0]->IsInt32()); | ||
| 2309 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2308 | + int fd; | ||
| 2309 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2310 | + return; | ||
| 2311 | + } | ||
| 2310 | 2312 | ||
| 2311 | 2313 | CHECK(Buffer::HasInstance(args[1])); | |
| 2312 | 2314 | Local<Object> buffer_obj = args[1].As<Object>(); | |
@@ -2372,8 +2374,10 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) { | |||
| 2372 | 2374 | const int argc = args.Length(); | |
| 2373 | 2375 | CHECK_GE(argc, 3); | |
| 2374 | 2376 | ||
| 2375 | - CHECK(args[0]->IsInt32()); | ||
| 2376 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2377 | + int fd; | ||
| 2378 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2379 | + return; | ||
| 2380 | + } | ||
| 2377 | 2381 | ||
| 2378 | 2382 | CHECK(args[1]->IsArray()); | |
| 2379 | 2383 | Local<Array> chunks = args[1].As<Array>(); | |
@@ -2432,8 +2436,10 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) { | |||
| 2432 | 2436 | ||
| 2433 | 2437 | const int argc = args.Length(); | |
| 2434 | 2438 | CHECK_GE(argc, 4); | |
| 2435 | - CHECK(args[0]->IsInt32()); | ||
| 2436 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2439 | + int fd; | ||
| 2440 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2441 | + return; | ||
| 2442 | + } | ||
| 2437 | 2443 | ||
| 2438 | 2444 | const int64_t pos = GetOffset(args[2]); | |
| 2439 | 2445 | ||
@@ -2625,8 +2631,10 @@ static void Read(const FunctionCallbackInfo<Value>& args) { | |||
| 2625 | 2631 | const int argc = args.Length(); | |
| 2626 | 2632 | CHECK_GE(argc, 5); | |
| 2627 | 2633 | ||
| 2628 | - CHECK(args[0]->IsInt32()); | ||
| 2629 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2634 | + int fd; | ||
| 2635 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2636 | + return; | ||
| 2637 | + } | ||
| 2630 | 2638 | ||
| 2631 | 2639 | CHECK(Buffer::HasInstance(args[1])); | |
| 2632 | 2640 | Local<Object> buffer_obj = args[1].As<Object>(); | |
@@ -2756,8 +2764,10 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) { | |||
| 2756 | 2764 | const int argc = args.Length(); | |
| 2757 | 2765 | CHECK_GE(argc, 3); | |
| 2758 | 2766 | ||
| 2759 | - CHECK(args[0]->IsInt32()); | ||
| 2760 | - const int fd = args[0].As<Int32>()->Value(); | ||
| 2767 | + int fd; | ||
| 2768 | + if (!GetValidatedFd(env, args[0]).To(&fd)) { | ||
| 2769 | + return; | ||
| 2770 | + } | ||
| 2761 | 2771 | ||
| 2762 | 2772 | CHECK(args[1]->IsArray()); | |
| 2763 | 2773 | Local<Array> buffers = args[1].As<Array>(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments