Skip to content

Commit 57fe96f

Browse files
F3lixTheCataduh95
authored andcommitted
src: added CHECK_NOT_NULL check for multiple eq_wrap_async
PR-URL: #59267 Fixes: #59266 Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 43b5a21 commit 57fe96f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/node_file.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
11401140
bool use_bigint = args[1]->IsTrue();
11411141
if (!args[2]->IsUndefined()) { // lstat(path, use_bigint, req)
11421142
FSReqBase* req_wrap_async = GetReqWrap(args, 2, use_bigint);
1143+
CHECK_NOT_NULL(req_wrap_async);
11431144
FS_ASYNC_TRACE_BEGIN1(
11441145
UV_FS_LSTAT, req_wrap_async, "path", TRACE_STR_COPY(*path))
11451146
AsyncCall(env, req_wrap_async, args, "lstat", UTF8, AfterStat,
@@ -1182,6 +1183,7 @@ static void FStat(const FunctionCallbackInfo<Value>& args) {
11821183
bool use_bigint = args[1]->IsTrue();
11831184
if (!args[2]->IsUndefined()) { // fstat(fd, use_bigint, req)
11841185
FSReqBase* req_wrap_async = GetReqWrap(args, 2, use_bigint);
1186+
CHECK_NOT_NULL(req_wrap_async);
11851187
FS_ASYNC_TRACE_BEGIN0(UV_FS_FSTAT, req_wrap_async)
11861188
AsyncCall(env, req_wrap_async, args, "fstat", UTF8, AfterStat,
11871189
uv_fs_fstat, fd);
@@ -1283,6 +1285,7 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
12831285

12841286
if (argc > 3) { // symlink(target, path, flags, req)
12851287
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
1288+
CHECK_NOT_NULL(req_wrap_async);
12861289
FS_ASYNC_TRACE_BEGIN2(UV_FS_SYMLINK,
12871290
req_wrap_async,
12881291
"target",
@@ -1321,6 +1324,7 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
13211324

13221325
if (argc > 2) { // link(src, dest, req)
13231326
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1327+
CHECK_NOT_NULL(req_wrap_async);
13241328
// To avoid bypass the link target should be allowed to read and write
13251329
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
13261330
env,
@@ -1379,6 +1383,7 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
13791383

13801384
if (argc > 2) { // readlink(path, encoding, req)
13811385
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1386+
CHECK_NOT_NULL(req_wrap_async);
13821387
FS_ASYNC_TRACE_BEGIN1(
13831388
UV_FS_READLINK, req_wrap_async, "path", TRACE_STR_COPY(*path))
13841389
AsyncCall(env, req_wrap_async, args, "readlink", encoding, AfterStringPtr,
@@ -1425,6 +1430,7 @@ static void Rename(const FunctionCallbackInfo<Value>& args) {
14251430

14261431
if (argc > 2) { // rename(old_path, new_path, req)
14271432
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1433+
CHECK_NOT_NULL(req_wrap_async);
14281434
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
14291435
env,
14301436
req_wrap_async,
@@ -1482,6 +1488,7 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) {
14821488

14831489
if (argc > 2) { // ftruncate(fd, len, req)
14841490
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1491+
CHECK_NOT_NULL(req_wrap_async);
14851492
FS_ASYNC_TRACE_BEGIN0(UV_FS_FTRUNCATE, req_wrap_async)
14861493
AsyncCall(env, req_wrap_async, args, "ftruncate", UTF8, AfterNoArgs,
14871494
uv_fs_ftruncate, fd, len);
@@ -1591,6 +1598,7 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
15911598

15921599
if (argc > 1) {
15931600
FSReqBase* req_wrap_async = GetReqWrap(args, 1); // rmdir(path, req)
1601+
CHECK_NOT_NULL(req_wrap_async);
15941602
FS_ASYNC_TRACE_BEGIN1(
15951603
UV_FS_RMDIR, req_wrap_async, "path", TRACE_STR_COPY(*path))
15961604
AsyncCall(env, req_wrap_async, args, "rmdir", UTF8, AfterNoArgs,
@@ -1788,6 +1796,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
17881796

17891797
if (argc > 3) { // mkdir(path, mode, recursive, req)
17901798
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
1799+
CHECK_NOT_NULL(req_wrap_async);
17911800
FS_ASYNC_TRACE_BEGIN1(
17921801
UV_FS_UNLINK, req_wrap_async, "path", TRACE_STR_COPY(*path))
17931802
AsyncCall(env, req_wrap_async, args, "mkdir", UTF8,
@@ -1839,6 +1848,7 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
18391848

18401849
if (argc > 2) { // realpath(path, encoding, req)
18411850
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1851+
CHECK_NOT_NULL(req_wrap_async);
18421852
FS_ASYNC_TRACE_BEGIN1(
18431853
UV_FS_REALPATH, req_wrap_async, "path", TRACE_STR_COPY(*path))
18441854
AsyncCall(env, req_wrap_async, args, "realpath", encoding, AfterStringPtr,
@@ -1906,6 +1916,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
19061916

19071917
if (argc > 3) { // readdir(path, encoding, withTypes, req)
19081918
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
1919+
CHECK_NOT_NULL(req_wrap_async);
19091920
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
19101921
env,
19111922
req_wrap_async,
@@ -2146,6 +2157,7 @@ static void CopyFile(const FunctionCallbackInfo<Value>& args) {
21462157

21472158
if (argc > 3) { // copyFile(src, dest, flags, req)
21482159
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2160+
CHECK_NOT_NULL(req_wrap_async);
21492161
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
21502162
env,
21512163
req_wrap_async,
@@ -2269,6 +2281,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
22692281

22702282
if (argc > 3) { // writeBuffers(fd, chunks, pos, req)
22712283
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2284+
CHECK_NOT_NULL(req_wrap_async);
22722285
FS_ASYNC_TRACE_BEGIN0(UV_FS_WRITE, req_wrap_async)
22732286
AsyncCall(env,
22742287
req_wrap_async,
@@ -2643,6 +2656,7 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
26432656

26442657
if (argc > 3) { // readBuffers(fd, buffers, pos, req)
26452658
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2659+
CHECK_NOT_NULL(req_wrap_async);
26462660
FS_ASYNC_TRACE_BEGIN0(UV_FS_READ, req_wrap_async)
26472661
AsyncCall(env, req_wrap_async, args, "read", UTF8, AfterInteger,
26482662
uv_fs_read, fd, *iovs, iovs.length(), pos);
@@ -2680,6 +2694,7 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
26802694

26812695
if (argc > 2) { // chmod(path, mode, req)
26822696
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
2697+
CHECK_NOT_NULL(req_wrap_async);
26832698
FS_ASYNC_TRACE_BEGIN1(
26842699
UV_FS_CHMOD, req_wrap_async, "path", TRACE_STR_COPY(*path))
26852700
AsyncCall(env, req_wrap_async, args, "chmod", UTF8, AfterNoArgs,
@@ -2712,6 +2727,7 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
27122727

27132728
if (argc > 2) { // fchmod(fd, mode, req)
27142729
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
2730+
CHECK_NOT_NULL(req_wrap_async);
27152731
FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHMOD, req_wrap_async)
27162732
AsyncCall(env, req_wrap_async, args, "fchmod", UTF8, AfterNoArgs,
27172733
uv_fs_fchmod, fd, mode);
@@ -2789,6 +2805,7 @@ static void FChown(const FunctionCallbackInfo<Value>& args) {
27892805

27902806
if (argc > 3) { // fchown(fd, uid, gid, req)
27912807
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2808+
CHECK_NOT_NULL(req_wrap_async);
27922809
FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHOWN, req_wrap_async)
27932810
AsyncCall(env, req_wrap_async, args, "fchown", UTF8, AfterNoArgs,
27942811
uv_fs_fchown, fd, uid, gid);
@@ -2819,6 +2836,7 @@ static void LChown(const FunctionCallbackInfo<Value>& args) {
28192836

28202837
if (argc > 3) { // lchown(path, uid, gid, req)
28212838
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2839+
CHECK_NOT_NULL(req_wrap_async);
28222840
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
28232841
env,
28242842
req_wrap_async,
@@ -2861,6 +2879,7 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) {
28612879

28622880
if (argc > 3) { // utimes(path, atime, mtime, req)
28632881
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2882+
CHECK_NOT_NULL(req_wrap_async);
28642883
FS_ASYNC_TRACE_BEGIN1(
28652884
UV_FS_UTIME, req_wrap_async, "path", TRACE_STR_COPY(*path))
28662885
AsyncCall(env, req_wrap_async, args, "utime", UTF8, AfterNoArgs,
@@ -2893,6 +2912,7 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) {
28932912

28942913
if (argc > 3) { // futimes(fd, atime, mtime, req)
28952914
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2915+
CHECK_NOT_NULL(req_wrap_async);
28962916
FS_ASYNC_TRACE_BEGIN0(UV_FS_FUTIME, req_wrap_async)
28972917
AsyncCall(env, req_wrap_async, args, "futime", UTF8, AfterNoArgs,
28982918
uv_fs_futime, fd, atime, mtime);
@@ -2925,6 +2945,7 @@ static void LUTimes(const FunctionCallbackInfo<Value>& args) {
29252945

29262946
if (argc > 3) { // lutimes(path, atime, mtime, req)
29272947
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2948+
CHECK_NOT_NULL(req_wrap_async);
29282949
FS_ASYNC_TRACE_BEGIN1(
29292950
UV_FS_LUTIME, req_wrap_async, "path", TRACE_STR_COPY(*path))
29302951
AsyncCall(env, req_wrap_async, args, "lutime", UTF8, AfterNoArgs,
@@ -2957,6 +2978,7 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
29572978

29582979
if (argc > 2) { // mkdtemp(tmpl, encoding, req)
29592980
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
2981+
CHECK_NOT_NULL(req_wrap_async);
29602982
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
29612983
env,
29622984
req_wrap_async,

0 commit comments

Comments
 (0)