efreet - protect efreetd from recursing too far to save overhead and mem

an errant path made its way into my efreet cache. this had a
side-effect of causing efreetd to scan my entire $HOME recursively
to monitor everything. while the original cause was $HOME getting in,
we shouldn't have efreetd sit and consume scan all of $HOME when this
is far from a normal situation. the recursive scanning is there ot
handle some minimal levels of subdirs in app directories, but not an
entire filesystem, so this mitigates the effects of errant cache data
by limiting the amount of recursion allows for icon dirs and desktop
dirs to 8 and 3 levels respectively.
This commit is contained in:
Carsten Haitzler 2013-12-04 20:22:26 +09:00
parent a1b57d3536
commit f6f28bf75a
1 changed files with 4 additions and 0 deletions

View File

@ -268,6 +268,8 @@ icon_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Bool b
if (stat(path, &st) == -1) return;
if (eina_inarray_search(stack, &st, stat_cmp) >= 0) return;
// protect against too deep recursion even if it's valid.
if (eina_inarray_count(stack) >= 8) return;
eina_inarray_push(stack, &st);
if ((!ecore_file_is_dir(path)) && (base))
@ -302,6 +304,8 @@ desktop_changes_listen_recursive(Eina_Inarray *stack, const char *path, Eina_Boo
if (stat(path, &st) == -1) return;
if (eina_inarray_search(stack, &st, stat_cmp) >= 0) return;
// protect against too deep recursion even if it's valid.
if (eina_inarray_count(stack) >= 3) return;
eina_inarray_push(stack, &st);
if ((!ecore_file_is_dir(path)) && (base))
{