Skip to content

Commit

Permalink
remove depth limits in from_ddwaf_object() (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-id authored Apr 2, 2024
1 parent e3febb4 commit 4efff47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,7 @@ ddwaf_object* to_ddwaf_object(
return to_ddwaf_object(object, env, val, depth, lim, ignoreToJson, JsSet::Create(env));
}

Napi::Value from_ddwaf_object(ddwaf_object *object, Napi::Env env, int depth) {
if (depth >= DDWAF_MAX_CONTAINER_DEPTH) {
mlog("Max depth reached");
return env.Null();
}

Napi::Value from_ddwaf_object(ddwaf_object *object, Napi::Env env) {
DDWAF_OBJ_TYPE type = object->type;

Napi::Value result;
Expand All @@ -246,7 +241,7 @@ Napi::Value from_ddwaf_object(ddwaf_object *object, Napi::Env env, int depth) {

for (uint32_t i = 0; i < object->nbEntries; ++i) {
ddwaf_object* e = &object->array[i];
Napi::Value v = from_ddwaf_object(e, env, depth + 1);
Napi::Value v = from_ddwaf_object(e, env);
arr[i] = v;
}

Expand All @@ -263,7 +258,7 @@ Napi::Value from_ddwaf_object(ddwaf_object *object, Napi::Env env, int depth) {
mlog("Exception pending");
continue;
}
Napi::Value v = from_ddwaf_object(e, env, depth + 1);
Napi::Value v = from_ddwaf_object(e, env);
obj.Set(k, v);
}

Expand Down
2 changes: 1 addition & 1 deletion src/convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ ddwaf_object* to_ddwaf_object(
bool ignoreToJson = false
);

Napi::Value from_ddwaf_object(ddwaf_object *object, Napi::Env env, int depth = 0);
Napi::Value from_ddwaf_object(ddwaf_object *object, Napi::Env env);

#endif // SRC_CONVERT_H_

0 comments on commit 4efff47

Please sign in to comment.