fixes crash in dav-sync archive command when trying to remove resources from the db

Sat, 23 Feb 2019 18:58:53 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 23 Feb 2019 18:58:53 +0100
changeset 506
ceed7714846a
parent 505
481802342fdf
child 507
dea7d1b4eea0

fixes crash in dav-sync archive command when trying to remove resources from the db

dav/sync.c file | annotate | diff | comparison | revisions
libidav/crypto.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Mon Feb 04 17:17:48 2019 +0100
+++ b/dav/sync.c	Sat Feb 23 18:58:53 2019 +0100
@@ -1191,7 +1191,6 @@
     
     UCX_FOREACH(elm, resources) {
         LocalResource *local_res = elm->data;
-        
         // ignore all files, that are excluded by a static filter (sync.xml) 
         
         // static include/exclude filter
@@ -1245,7 +1244,8 @@
     // find all deleted files and cleanup the database
     UcxMapIterator i = ucx_map_iterator(db->resources);
     LocalResource *local;
-    UCX_MAP_FOREACH(key, local, i) {
+    UcxList *removed_res = NULL;
+    UCX_MAP_FOREACH(key, local, i) { 
         // all filtered files should be removed from the database
         if(res_matches_filter(dir, local->path+1)) {
             ucx_map_cstr_remove(db->resources, local->path);
@@ -1266,10 +1266,14 @@
             if(!archive) {
                 ls_delete = ucx_list_append(ls_delete, local);
             } else {
-                ucx_map_cstr_remove(db->resources, local->path);
+                removed_res = ucx_list_prepend(removed_res, local);
             }
         }
     }
+    UCX_FOREACH(elm, removed_res) {
+        LocalResource *local = elm->data;
+        ucx_map_cstr_remove(db->resources, local->path);
+    }
     
     ls_delete = ucx_list_sort(ls_delete, (cmp_func)resource_pathlen_cmp, NULL);
     
--- a/libidav/crypto.c	Mon Feb 04 17:17:48 2019 +0100
+++ b/libidav/crypto.c	Sat Feb 23 18:58:53 2019 +0100
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <libidav/utils.h>
+#include "utils.h"
 
 #include "crypto.h"
 

mercurial