fixes wrong buffer allocation on windows v1.2

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

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 19 Jul 2018 16:28:37 +0200
branch
v1.2
changeset 453
68a786fa4695
parent 452
e48af5bfb637
child 454
fefddd41387e

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 15:46:15 2018 +0200
+++ b/dav/sync.c	Thu Jul 19 16:28:37 2018 +0200
@@ -1255,7 +1255,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 15:46:15 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 15:46:15 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