fixes wrong buffer allocation on windows

Thu, 19 Jul 2018 16:28:37 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 19 Jul 2018 16:28:37 +0200
changeset 447
a4a71ecfb9d6
parent 446
cb61f2e1c25e
child 448
3bef733c55b3

fixes wrong buffer allocation on windows

dav/sync.c file | annotate | diff | comparison | revisions
dav/system.c file | annotate | diff | comparison | revisions
dav/system.h file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Wed Jul 11 17:08:25 2018 +0200
+++ b/dav/sync.c	Thu Jul 19 16:28:37 2018 +0200
@@ -1291,7 +1291,7 @@
                 }
                 
                 char *new_path = util_concat_path(p, ent->name);
-                int isdir;
+                int isdir = 0;
                 LocalResource *res = local_resource_new(dir, db, new_path, &isdir);
                 if(isdir) {
                     resources = ucx_list_append(resources, res);
--- a/dav/system.c	Wed Jul 11 17:08:25 2018 +0200
+++ b/dav/system.c	Thu Jul 19 16:28:37 2018 +0200
@@ -100,7 +100,11 @@
 }
 
 int sys_mkdir(const char *path) {
+#ifdef _WIN32
+    return mkdir(path);
+#else
     return mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+#endif
 }
 
 #else
@@ -111,7 +115,7 @@
     size_t lenadd = dir ? 2 : 0;
     
     
-    wchar_t *wpath = calloc(len+lenadd, sizeof(wchar_t));
+    wchar_t *wpath = calloc(len+lenadd+1, sizeof(wchar_t));
     int wlen = MultiByteToWideChar(
             CP_UTF8,
             0,
--- a/dav/system.h	Wed Jul 11 17:08:25 2018 +0200
+++ b/dav/system.h	Thu Jul 19 16:28:37 2018 +0200
@@ -54,6 +54,10 @@
     WIN32_FIND_DATAW finddata;
     SysDirEnt *ent;
 };
+typedef struct SysDir {
+    DIR *dir;
+    SysDirEnt *ent;
+} SysDir;
 #define SYS_DIR struct WinDir*
 #define SYS_STAT struct __stat64
 

mercurial