aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-01-25 06:57:35 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2013-01-25 06:57:35 +0000
commit24dee8e93577c0b538b37f5d88fd19f6b39a7961 (patch)
tree59ff997b6c656f12781b2077646c4e02dd382e2a /libsylph
parent8da6ea27d310eecb9cdbc1ccb9283bc6fbdd86bf (diff)
limit the recursion level of tree scan to 64.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3197 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/mh.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/libsylph/mh.c b/libsylph/mh.c
index 89ba6baa..e8afa6b9 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -1665,6 +1665,8 @@ static void mh_remove_missing_folder_items(Folder *folder)
mh_remove_missing_folder_items_func, folder);
}
+#define MAX_RECURSION_LEVEL 64
+
static void mh_scan_tree_recursive(FolderItem *item)
{
Folder *folder;
@@ -1691,6 +1693,32 @@ static void mh_scan_tree_recursive(FolderItem *item)
folder = item->folder;
+ debug_print("scanning %s ...\n",
+ item->path ? item->path : LOCAL_FOLDER(folder)->rootpath);
+ if (folder->ui_func)
+ folder->ui_func(folder, item, folder->ui_func_data);
+
+ if (item->path) {
+ gint new, unread, total, min, max;
+
+ procmsg_get_mark_sum
+ (item, &new, &unread, &total, &min, &max, 0);
+ if (n_msg > total) {
+ new += n_msg - total;
+ unread += n_msg - total;
+ }
+ item->new = new;
+ item->unread = unread;
+ item->total = n_msg;
+ item->updated = TRUE;
+ item->mtime = 0;
+ }
+
+ if (g_node_depth(item->node) >= MAX_RECURSION_LEVEL) {
+ g_warning("mh_scan_tree_recursive(): max recursion level (%u) reached.", MAX_RECURSION_LEVEL);
+ return;
+ }
+
fs_path = item->path ?
g_filename_from_utf8(item->path, -1, NULL, NULL, NULL)
: g_strdup(".");
@@ -1713,12 +1741,6 @@ static void mh_scan_tree_recursive(FolderItem *item)
#endif
g_free(fs_path);
- debug_print("scanning %s ...\n",
- item->path ? item->path
- : LOCAL_FOLDER(item->folder)->rootpath);
- if (folder->ui_func)
- folder->ui_func(folder, item, folder->ui_func_data);
-
#ifdef G_OS_WIN32
do {
if (!wfd.file_name) continue;
@@ -1845,22 +1867,6 @@ static void mh_scan_tree_recursive(FolderItem *item)
#else
closedir(dp);
#endif
-
- if (item->path) {
- gint new, unread, total, min, max;
-
- procmsg_get_mark_sum
- (item, &new, &unread, &total, &min, &max, 0);
- if (n_msg > total) {
- new += n_msg - total;
- unread += n_msg - total;
- }
- item->new = new;
- item->unread = unread;
- item->total = n_msg;
- item->updated = TRUE;
- item->mtime = 0;
- }
}
static gboolean mh_rename_folder_func(GNode *node, gpointer data)