From: Jon Trulson Date: Thu, 5 Apr 2018 18:49:06 +0000 (-0600) Subject: dtfile: define MAX_PATH to PATH_MAX rather than 1024, also CID 87557 X-Git-Tag: 2.2.4a~124 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=caa95ba67ce3432a4e830bfd9e0b3d5d0433807a;p=oweals%2Fcde.git dtfile: define MAX_PATH to PATH_MAX rather than 1024, also CID 87557 --- diff --git a/cde/programs/dtfile/ChangeDir.c b/cde/programs/dtfile/ChangeDir.c index 7ee48506..71dbf1cf 100644 --- a/cde/programs/dtfile/ChangeDir.c +++ b/cde/programs/dtfile/ChangeDir.c @@ -106,7 +106,7 @@ #include "SharedMsgs.h" -#define MAX_PATH 1024 +#define MAX_PATH PATH_MAX static char * CHANGEDIRECTORY = "ChangeDirectory"; diff --git a/cde/programs/dtfile/Directory.c b/cde/programs/dtfile/Directory.c index 460e3df7..f8ed2fb4 100644 --- a/cde/programs/dtfile/Directory.c +++ b/cde/programs/dtfile/Directory.c @@ -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)) diff --git a/cde/programs/dtfile/Main.h b/cde/programs/dtfile/Main.h index bb500846..05c4ddd1 100644 --- a/cde/programs/dtfile/Main.h +++ b/cde/programs/dtfile/Main.h @@ -75,7 +75,7 @@ /* Generally used defines */ -#define MAX_PATH 1024 +#define MAX_PATH PATH_MAX #define BLOCK_SIZE 1024 #define BUF_SIZE 256 diff --git a/cde/programs/dtfile/dtcopy/dtcopy.h b/cde/programs/dtfile/dtcopy/dtcopy.h index 4a15453c..13a2320c 100644 --- a/cde/programs/dtfile/dtcopy/dtcopy.h +++ b/cde/programs/dtfile/dtcopy/dtcopy.h @@ -39,7 +39,7 @@ ************************************<+>*************************************/ /* Macros */ -#define MAX_PATH 1024 +#define MAX_PATH PATH_MAX #define G_OVERWRITE_EXISTING 0 #define G_SKIP 1 diff --git a/cde/programs/dtfile/dtcopy/sharedFuncs.h b/cde/programs/dtfile/dtcopy/sharedFuncs.h index 775b8727..c1943743 100644 --- a/cde/programs/dtfile/dtcopy/sharedFuncs.h +++ b/cde/programs/dtfile/dtcopy/sharedFuncs.h @@ -49,7 +49,8 @@ #define TIGHTNESS 20 /* button spacing in Create_Action_Area */ -#define MAX_PATH 1024 /* Maximum path length */ +#include +#define MAX_PATH PATH_MAX /* Maximum path length */ /* Types */