From 111ba769f4d43be45d90811f0d5fed91f81b6be1 Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Sat, 31 Jul 2021 09:06:44 -0400
Subject: [PATCH] Make max depth smaller for #1859 and #2349

---
 tsk/fs/fs_dir.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tsk/fs/fs_dir.c b/tsk/fs/fs_dir.c
index ae526bec3..cebfae8aa 100644
--- a/tsk/fs/fs_dir.c
+++ b/tsk/fs/fs_dir.c
@@ -927,8 +927,10 @@ tsk_fs_dir_internal_walk(TSK_FS_INFO * a_fs, TSK_INUM_T a_addr,
         return 1;
     }
 
-    // 256 is an arbitrary chosen value.
-    if (recursion_depth > 256) {
+    // 128 is a somewhat arbitrary value.
+    // https://github.com/sleuthkit/sleuthkit/issues/1859 identified
+    // an overflow with 240 levels of recursion
+    if (recursion_depth > 128) {
         tsk_error_set_errno(TSK_ERR_FS_ARG);
         tsk_error_set_errstr
             ("tsk_fs_dir_internal_walk: recursion depth exceeds maximum (%d)", recursion_depth);
-- 
GitLab