dtfile: define MAX_PATH to PATH_MAX rather than 1024, also CID 87557
authorJon Trulson <jon@radscan.com>
Thu, 5 Apr 2018 18:49:06 +0000 (12:49 -0600)
committerJon Trulson <jon@radscan.com>
Thu, 5 Apr 2018 18:49:06 +0000 (12:49 -0600)
cde/programs/dtfile/ChangeDir.c
cde/programs/dtfile/Directory.c
cde/programs/dtfile/Main.h
cde/programs/dtfile/dtcopy/dtcopy.h
cde/programs/dtfile/dtcopy/sharedFuncs.h

index 7ee4850652858e3786249c312c8347784f683e9a..71dbf1cf04452b68582f2f64214a32ccd7f6c58d 100644 (file)
 #include "SharedMsgs.h"
 
 
-#define MAX_PATH 1024
+#define MAX_PATH PATH_MAX
 
 static char * CHANGEDIRECTORY = "ChangeDirectory";
 
index 460e3df7845d0bf46a29b1783e11f5e9a478690a..f8ed2fb47fefa8681530d1364b996e9e9f875788 100644 (file)
@@ -2857,11 +2857,14 @@ _ReadDir(
     /* read subdirectory */
     if (fp->is_subdir)
     {
-      /* construct sub directory name */
-      strcpy(subdir_name, directory_name);
-      if (subdir_name[strlen(subdir_name) - 1] != '/')
-        strcat(subdir_name, "/");
-      strcat(subdir_name, fp->file_name);
+        /* construct sub directory name */
+        strncpy(subdir_name, directory_name, MAX_PATH - 1);
+        if (strlen(subdir_name) > 0
+            && subdir_name[strlen(subdir_name) - 1] != '/')
+            strncat(subdir_name, "/", MAX_PATH - 1);
+
+        strncat(subdir_name, fp->file_name, MAX_PATH - 1);
+        subdir_name[MAX_PATH - 1] = 0;
 
       /* see if we know this entry from branch_list */
       if (!QueryBranchList(file_mgr_data, branch_list, subdir_name, &ts))
index bb5008462e32ea564ea45df2e663499e21534edb..05c4ddd1ed01d26a2238cdadd77896a0afaf1018 100644 (file)
@@ -75,7 +75,7 @@
 
 /*  Generally used defines  */
 
-#define MAX_PATH        1024
+#define MAX_PATH        PATH_MAX
 #define BLOCK_SIZE      1024
 #define BUF_SIZE        256
 
index 4a15453c4ba4e5c513c0e589f5588fee3cb547c2..13a2320cc209c05e3dc784023826c667e1213e9d 100644 (file)
@@ -39,7 +39,7 @@
  ************************************<+>*************************************/
 
 /* Macros */
-#define MAX_PATH      1024
+#define MAX_PATH      PATH_MAX
 
 #define G_OVERWRITE_EXISTING           0
 #define G_SKIP                         1
index 775b872744dc2b2caab9fd37246cddcba34533fb..c1943743799fefe6083178e65e11b41c6761ff6e 100644 (file)
@@ -49,7 +49,8 @@
 
 #define TIGHTNESS 20   /* button spacing in Create_Action_Area */
 
-#define MAX_PATH  1024   /* Maximum path length */
+#include <limits.h>
+#define MAX_PATH  PATH_MAX   /* Maximum path length */
 
 /* Types  */