fixes infinite loop when trying to overwrite a collection with a regular file v1.1

Tue, 12 Dec 2017 23:58:54 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 12 Dec 2017 23:58:54 +0100
branch
v1.1
changeset 343
b9c6e0be5774
parent 342
0b03aa8fb838

fixes infinite loop when trying to overwrite a collection with a regular file

dav/main.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Tue Dec 12 23:36:47 2017 +0100
+++ b/dav/main.c	Tue Dec 12 23:58:54 2017 +0100
@@ -922,6 +922,15 @@
     } else if(res->iscollection) {
         // TODO: free res
         char *newpath = util_concat_path(path, name);
+        
+        if (!strcmp(path, newpath)) {
+            // TODO: free res
+            fprintf(stderr, "Cannot put file, because a collection with "
+                    "that name already exists.\n");
+            free(newpath);
+            return -1;
+        }
+        
         path = newpath;
         res = dav_resource_new(sn, path);
         free(newpath);

mercurial