Skip to content

Commit

Permalink
fix: dde-grand-search crash
Browse files Browse the repository at this point in the history
Recursive search for files in the directory, recursive 200 layers causing stack overflow

Log: dde-grand-search crash
Bug: https://pms.uniontech.com/bug-view-270417.html
  • Loading branch information
liyigang1 committed Sep 25, 2024
1 parent ea28404 commit 9aade16
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions 3rdparty/fsearch/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// add py index,update database version to 1.0
#define DATABASE_MAJOR_VERSION 1
#define DATABASE_MINOR_VERSION 0

#define MAX_DIR_DEPTH 100

struct _DatabaseLocation
{
Expand Down Expand Up @@ -438,7 +438,8 @@ db_location_walk_tree_recursive (DatabaseLocation *location,
GTimer *timer,
void (*callback)(const char *),
BTreeNode *parent,
int spec)
int spec,
const int depth)
{
int len = strlen (dname);
if (len >= FILENAME_MAX - 1) {
Expand Down Expand Up @@ -504,15 +505,16 @@ db_location_walk_tree_recursive (DatabaseLocation *location,
is_dir);
btree_node_prepend (parent, node);
location->num_items++;
if (is_dir) {
if (is_dir && depth <= MAX_DIR_DEPTH) {
db_location_walk_tree_recursive (location,
excludes,
exclude_files,
fn,
timer,
callback,
node,
spec);
spec,
depth + 1);

}
}
Expand Down Expand Up @@ -552,7 +554,8 @@ db_location_build_tree (const char *dname, void (*callback)(const char *))
timer,
callback,
root,
spec);
spec,
0);
config_free(config);
g_timer_destroy (timer);
if (res == WALK_OK) {
Expand Down

0 comments on commit 9aade16

Please sign in to comment.