efreet - protect efreetd from recursing too far to save overhead and mem
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Wed, 4 Dec 2013 11:22:26 +0000 (20:22 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Wed, 4 Dec 2013 11:25:57 +0000 (20:25 +0900)
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.

src/bin/efreet/efreetd_cache.c

index 94e48f1..5b45487 100644 (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))
      {