| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e6a27a7 commit 53a67ed
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,25 +120,19 @@ class ProcessWrap : public HandleWrap { | |||
| 120 | 120 | // options.uid | |
| 121 | 121 | Local<Value> uid_v = js_options->Get(env->uid_string()); | |
| 122 | 122 | if (uid_v->IsInt32()) { | |
| 123 | - int32_t uid = uid_v->Int32Value(); | ||
| 124 | - if (uid & ~((uv_uid_t) ~0)) { | ||
| 125 | - return env->ThrowRangeError("options.uid is out of range"); | ||
| 126 | - } | ||
| 123 | + const int32_t uid = uid_v->Int32Value(env->context()).FromJust(); | ||
| 127 | 124 | options.flags |= UV_PROCESS_SETUID; | |
| 128 | - options.uid = (uv_uid_t) uid; | ||
| 125 | + options.uid = static_cast<uv_uid_t>(uid); | ||
| 129 | 126 | } else if (!uid_v->IsUndefined() && !uid_v->IsNull()) { | |
| 130 | 127 | return env->ThrowTypeError("options.uid should be a number"); | |
| 131 | 128 | } | |
| 132 | 129 | ||
| 133 | 130 | // options.gid | |
| 134 | 131 | Local<Value> gid_v = js_options->Get(env->gid_string()); | |
| 135 | 132 | if (gid_v->IsInt32()) { | |
| 136 | - int32_t gid = gid_v->Int32Value(); | ||
| 137 | - if (gid & ~((uv_gid_t) ~0)) { | ||
| 138 | - return env->ThrowRangeError("options.gid is out of range"); | ||
| 139 | - } | ||
| 133 | + const int32_t gid = gid_v->Int32Value(env->context()).FromJust(); | ||
| 140 | 134 | options.flags |= UV_PROCESS_SETGID; | |
| 141 | - options.gid = (uv_gid_t) gid; | ||
| 135 | + options.gid = static_cast<uv_gid_t>(gid); | ||
| 142 | 136 | } else if (!gid_v->IsUndefined() && !gid_v->IsNull()) { | |
| 143 | 137 | return env->ThrowTypeError("options.gid should be a number"); | |
| 144 | 138 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -729,17 +729,19 @@ int SyncProcessRunner::ParseOptions(Local<Value> js_value) { | |||
| 729 | 729 | } | |
| 730 | 730 | Local<Value> js_uid = js_options->Get(env()->uid_string()); | |
| 731 | 731 | if (IsSet(js_uid)) { | |
| 732 | - if (!CheckRange<uv_uid_t>(js_uid)) | ||
| 732 | + if (!js_uid->IsInt32()) | ||
| 733 | 733 | return UV_EINVAL; | |
| 734 | - uv_process_options_.uid = static_cast<uv_gid_t>(js_uid->Int32Value()); | ||
| 734 | + const int32_t uid = js_uid->Int32Value(env()->context()).FromJust(); | ||
| 735 | + uv_process_options_.uid = static_cast<uv_uid_t>(uid); | ||
| 735 | 736 | uv_process_options_.flags |= UV_PROCESS_SETUID; | |
| 736 | 737 | } | |
| 737 | 738 | ||
| 738 | 739 | Local<Value> js_gid = js_options->Get(env()->gid_string()); | |
| 739 | 740 | if (IsSet(js_gid)) { | |
| 740 | - if (!CheckRange<uv_gid_t>(js_gid)) | ||
| 741 | + if (!js_gid->IsInt32()) | ||
| 741 | 742 | return UV_EINVAL; | |
| 742 | - uv_process_options_.gid = static_cast<uv_gid_t>(js_gid->Int32Value()); | ||
| 743 | + const int32_t gid = js_gid->Int32Value(env()->context()).FromJust(); | ||
| 744 | + uv_process_options_.gid = static_cast<uv_gid_t>(gid); | ||
| 743 | 745 | uv_process_options_.flags |= UV_PROCESS_SETGID; | |
| 744 | 746 | } | |
| 745 | 747 | ||
@@ -763,7 +765,7 @@ int SyncProcessRunner::ParseOptions(Local<Value> js_value) { | |||
| 763 | 765 | ||
| 764 | 766 | Local<Value> js_max_buffer = js_options->Get(env()->max_buffer_string()); | |
| 765 | 767 | if (IsSet(js_max_buffer)) { | |
| 766 | - if (!CheckRange<uint32_t>(js_max_buffer)) | ||
| 768 | + if (!js_max_buffer->IsUint32()) | ||
| 767 | 769 | return UV_EINVAL; | |
| 768 | 770 | max_buffer_ = js_max_buffer->Uint32Value(); | |
| 769 | 771 | } | |
@@ -915,27 +917,6 @@ bool SyncProcessRunner::IsSet(Local<Value> value) { | |||
| 915 | 917 | } | |
| 916 | 918 | ||
| 917 | 919 | ||
| 918 | - template <typename t> | ||
| 919 | - bool SyncProcessRunner::CheckRange(Local<Value> js_value) { | ||
| 920 | - if ((t) -1 > 0) { | ||
| 921 | - // Unsigned range check. | ||
| 922 | - if (!js_value->IsUint32()) | ||
| 923 | - return false; | ||
| 924 | - if (js_value->Uint32Value() & ~((t) ~0)) | ||
| 925 | - return false; | ||
| 926 | - | ||
| 927 | - } else { | ||
| 928 | - // Signed range check. | ||
| 929 | - if (!js_value->IsInt32()) | ||
| 930 | - return false; | ||
| 931 | - if (js_value->Int32Value() & ~((t) ~0)) | ||
| 932 | - return false; | ||
| 933 | - } | ||
| 934 | - | ||
| 935 | - return true; | ||
| 936 | - } | ||
| 937 | - | ||
| 938 | - | ||
| 939 | 920 | int SyncProcessRunner::CopyJsString(Local<Value> js_value, | |
| 940 | 921 | const char** target) { | |
| 941 | 922 | Isolate* isolate = env()->isolate(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,7 +173,6 @@ class SyncProcessRunner { | |||
| 173 | 173 | inline int AddStdioInheritFD(uint32_t child_fd, int inherit_fd); | |
| 174 | 174 | ||
| 175 | 175 | static bool IsSet(Local<Value> value); | |
| 176 | - template <typename t> static bool CheckRange(Local<Value> js_value); | ||
| 177 | 176 | int CopyJsString(Local<Value> js_value, const char** target); | |
| 178 | 177 | int CopyJsStringArray(Local<Value> js_value, char** target); | |
| 179 | 178 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments