fixed filetransfer stopping because of invalid dirnames.
authorSimon Brandner <simon.brandner@partner.bmw.de>
Mon, 29 Apr 2013 10:32:57 +0000 (12:32 +0200)
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Fri, 19 Jul 2013 14:54:34 +0000 (16:54 +0200)
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
src/system/dlt-system-filetransfer.c

index 504468b..786c13e 100644 (file)
@@ -235,16 +235,14 @@ int send_one(char *src, FiletransferOptions const *opts, int which)
 
     // Prepare all needed file names
     char *fn = basename(src);
-    char *fdir = malloc(strlen(src)+1);
+
+    char *fdir = strndup(src,PATH_MAX);
     MALLOC_ASSERT(fdir);
-    strncpy(fdir,src,strlen(src));
-    *(fdir+strlen(fdir))='\0';
     fdir = dirname(fdir);//dirname overwrites its argument anyway
     char *dst_tosend;//file which is going to be sent
 
     char *rn = unique_name(src);//new unique filename based on inode
 
-
     MALLOC_ASSERT(fn);
     MALLOC_ASSERT(rn);
 
@@ -263,9 +261,6 @@ int send_one(char *src, FiletransferOptions const *opts, int which)
 
         snprintf(dst_tocompress,len,"%s/%s/%s",fdir,SUBDIR_COMPRESS,rn);
 
-
-
-
         //moving in subdir, from where it can be compressed
         if(rename(src, dst_tocompress) < 0)
         {