Skip to content

Commit 80dc61e

Browse files
F3lixTheCatmeteorqz6
authored andcommitted
src: added CHECK_NOT_NULL check for multiple eq_wrap_async
PR-URL: nodejs#59267 Fixes: nodejs#59266 Reviewed-By: Zeyu "Alex" Yang <[email protected]> Reviewed-By: theanarkh <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent ae45641 commit 80dc61e

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
@@ -1143,6 +1143,7 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
11431143
bool use_bigint = args[1]->IsTrue();
11441144
if (!args[2]->IsUndefined()) { // lstat(path, use_bigint, req)
11451145
FSReqBase* req_wrap_async = GetReqWrap(args, 2, use_bigint);
1146+
CHECK_NOT_NULL(req_wrap_async);
11461147
FS_ASYNC_TRACE_BEGIN1(
11471148
UV_FS_LSTAT, req_wrap_async, "path", TRACE_STR_COPY(*path))
11481149
AsyncCall(env, req_wrap_async, args, "lstat", UTF8, AfterStat,
@@ -1185,6 +1186,7 @@ static void FStat(const FunctionCallbackInfo<Value>& args) {
11851186
bool use_bigint = args[1]->IsTrue();
11861187
if (!args[2]->IsUndefined()) { // fstat(fd, use_bigint, req)
11871188
FSReqBase* req_wrap_async = GetReqWrap(args, 2, use_bigint);
1189+
CHECK_NOT_NULL(req_wrap_async);
11881190
FS_ASYNC_TRACE_BEGIN0(UV_FS_FSTAT, req_wrap_async)
11891191
AsyncCall(env, req_wrap_async, args, "fstat", UTF8, AfterStat,
11901192
uv_fs_fstat, fd);
@@ -1286,6 +1288,7 @@ static void Symlink(const FunctionCallbackInfo<Value>& args) {
12861288

12871289
if (argc > 3) { // symlink(target, path, flags, req)
12881290
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
1291+
CHECK_NOT_NULL(req_wrap_async);
12891292
FS_ASYNC_TRACE_BEGIN2(UV_FS_SYMLINK,
12901293
req_wrap_async,
12911294
"target",
@@ -1324,6 +1327,7 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
13241327

13251328
if (argc > 2) { // link(src, dest, req)
13261329
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1330+
CHECK_NOT_NULL(req_wrap_async);
13271331
// To avoid bypass the link target should be allowed to read and write
13281332
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
13291333
env,
@@ -1382,6 +1386,7 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
13821386

13831387
if (argc > 2) { // readlink(path, encoding, req)
13841388
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1389+
CHECK_NOT_NULL(req_wrap_async);
13851390
FS_ASYNC_TRACE_BEGIN1(
13861391
UV_FS_READLINK, req_wrap_async, "path", TRACE_STR_COPY(*path))
13871392
AsyncCall(env, req_wrap_async, args, "readlink", encoding, AfterStringPtr,
@@ -1422,6 +1427,7 @@ static void Rename(const FunctionCallbackInfo<Value>& args) {
14221427

14231428
if (argc > 2) { // rename(old_path, new_path, req)
14241429
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1430+
CHECK_NOT_NULL(req_wrap_async);
14251431
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
14261432
env,
14271433
req_wrap_async,
@@ -1479,6 +1485,7 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) {
14791485

14801486
if (argc > 2) { // ftruncate(fd, len, req)
14811487
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1488+
CHECK_NOT_NULL(req_wrap_async);
14821489
FS_ASYNC_TRACE_BEGIN0(UV_FS_FTRUNCATE, req_wrap_async)
14831490
AsyncCall(env, req_wrap_async, args, "ftruncate", UTF8, AfterNoArgs,
14841491
uv_fs_ftruncate, fd, len);
@@ -1588,6 +1595,7 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
15881595

15891596
if (argc > 1) {
15901597
FSReqBase* req_wrap_async = GetReqWrap(args, 1); // rmdir(path, req)
1598+
CHECK_NOT_NULL(req_wrap_async);
15911599
FS_ASYNC_TRACE_BEGIN1(
15921600
UV_FS_RMDIR, req_wrap_async, "path", TRACE_STR_COPY(*path))
15931601
AsyncCall(env, req_wrap_async, args, "rmdir", UTF8, AfterNoArgs,
@@ -1885,6 +1893,7 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
18851893

18861894
if (argc > 3) { // mkdir(path, mode, recursive, req)
18871895
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
1896+
CHECK_NOT_NULL(req_wrap_async);
18881897
FS_ASYNC_TRACE_BEGIN1(
18891898
UV_FS_UNLINK, req_wrap_async, "path", TRACE_STR_COPY(*path))
18901899
AsyncCall(env, req_wrap_async, args, "mkdir", UTF8,
@@ -1931,6 +1940,7 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
19311940

19321941
if (argc > 2) { // realpath(path, encoding, req)
19331942
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
1943+
CHECK_NOT_NULL(req_wrap_async);
19341944
FS_ASYNC_TRACE_BEGIN1(
19351945
UV_FS_REALPATH, req_wrap_async, "path", TRACE_STR_COPY(*path))
19361946
AsyncCall(env, req_wrap_async, args, "realpath", encoding, AfterStringPtr,
@@ -1992,6 +2002,7 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
19922002

19932003
if (argc > 3) { // readdir(path, encoding, withTypes, req)
19942004
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2005+
CHECK_NOT_NULL(req_wrap_async);
19952006
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
19962007
env,
19972008
req_wrap_async,
@@ -2239,6 +2250,7 @@ static void CopyFile(const FunctionCallbackInfo<Value>& args) {
22392250

22402251
if (argc > 3) { // copyFile(src, dest, flags, req)
22412252
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2253+
CHECK_NOT_NULL(req_wrap_async);
22422254
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
22432255
env,
22442256
req_wrap_async,
@@ -2374,6 +2386,7 @@ static void WriteBuffers(const FunctionCallbackInfo<Value>& args) {
23742386

23752387
if (argc > 3) { // writeBuffers(fd, chunks, pos, req)
23762388
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2389+
CHECK_NOT_NULL(req_wrap_async);
23772390
FS_ASYNC_TRACE_BEGIN0(UV_FS_WRITE, req_wrap_async)
23782391
AsyncCall(env,
23792392
req_wrap_async,
@@ -2758,6 +2771,7 @@ static void ReadBuffers(const FunctionCallbackInfo<Value>& args) {
27582771

27592772
if (argc > 3) { // readBuffers(fd, buffers, pos, req)
27602773
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2774+
CHECK_NOT_NULL(req_wrap_async);
27612775
FS_ASYNC_TRACE_BEGIN0(UV_FS_READ, req_wrap_async)
27622776
AsyncCall(env, req_wrap_async, args, "read", UTF8, AfterInteger,
27632777
uv_fs_read, fd, *iovs, iovs.length(), pos);
@@ -2795,6 +2809,7 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
27952809

27962810
if (argc > 2) { // chmod(path, mode, req)
27972811
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
2812+
CHECK_NOT_NULL(req_wrap_async);
27982813
FS_ASYNC_TRACE_BEGIN1(
27992814
UV_FS_CHMOD, req_wrap_async, "path", TRACE_STR_COPY(*path))
28002815
AsyncCall(env, req_wrap_async, args, "chmod", UTF8, AfterNoArgs,
@@ -2827,6 +2842,7 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
28272842

28282843
if (argc > 2) { // fchmod(fd, mode, req)
28292844
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
2845+
CHECK_NOT_NULL(req_wrap_async);
28302846
FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHMOD, req_wrap_async)
28312847
AsyncCall(env, req_wrap_async, args, "fchmod", UTF8, AfterNoArgs,
28322848
uv_fs_fchmod, fd, mode);
@@ -2904,6 +2920,7 @@ static void FChown(const FunctionCallbackInfo<Value>& args) {
29042920

29052921
if (argc > 3) { // fchown(fd, uid, gid, req)
29062922
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2923+
CHECK_NOT_NULL(req_wrap_async);
29072924
FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHOWN, req_wrap_async)
29082925
AsyncCall(env, req_wrap_async, args, "fchown", UTF8, AfterNoArgs,
29092926
uv_fs_fchown, fd, uid, gid);
@@ -2934,6 +2951,7 @@ static void LChown(const FunctionCallbackInfo<Value>& args) {
29342951

29352952
if (argc > 3) { // lchown(path, uid, gid, req)
29362953
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2954+
CHECK_NOT_NULL(req_wrap_async);
29372955
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
29382956
env,
29392957
req_wrap_async,
@@ -2976,6 +2994,7 @@ static void UTimes(const FunctionCallbackInfo<Value>& args) {
29762994

29772995
if (argc > 3) { // utimes(path, atime, mtime, req)
29782996
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
2997+
CHECK_NOT_NULL(req_wrap_async);
29792998
FS_ASYNC_TRACE_BEGIN1(
29802999
UV_FS_UTIME, req_wrap_async, "path", TRACE_STR_COPY(*path))
29813000
AsyncCall(env, req_wrap_async, args, "utime", UTF8, AfterNoArgs,
@@ -3008,6 +3027,7 @@ static void FUTimes(const FunctionCallbackInfo<Value>& args) {
30083027

30093028
if (argc > 3) { // futimes(fd, atime, mtime, req)
30103029
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
3030+
CHECK_NOT_NULL(req_wrap_async);
30113031
FS_ASYNC_TRACE_BEGIN0(UV_FS_FUTIME, req_wrap_async)
30123032
AsyncCall(env, req_wrap_async, args, "futime", UTF8, AfterNoArgs,
30133033
uv_fs_futime, fd, atime, mtime);
@@ -3040,6 +3060,7 @@ static void LUTimes(const FunctionCallbackInfo<Value>& args) {
30403060

30413061
if (argc > 3) { // lutimes(path, atime, mtime, req)
30423062
FSReqBase* req_wrap_async = GetReqWrap(args, 3);
3063+
CHECK_NOT_NULL(req_wrap_async);
30433064
FS_ASYNC_TRACE_BEGIN1(
30443065
UV_FS_LUTIME, req_wrap_async, "path", TRACE_STR_COPY(*path))
30453066
AsyncCall(env, req_wrap_async, args, "lutime", UTF8, AfterNoArgs,
@@ -3072,6 +3093,7 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
30723093

30733094
if (argc > 2) { // mkdtemp(tmpl, encoding, req)
30743095
FSReqBase* req_wrap_async = GetReqWrap(args, 2);
3096+
CHECK_NOT_NULL(req_wrap_async);
30753097
ASYNC_THROW_IF_INSUFFICIENT_PERMISSIONS(
30763098
env,
30773099
req_wrap_async,

0 commit comments

Comments
 (0)