diff --git a/cde/programs/dtfile/ChangeDir.c b/cde/programs/dtfile/ChangeDir.c index 7ee485065..71dbf1cf0 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 460e3df78..f8ed2fb47 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 bb5008462..05c4ddd1e 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 4a15453c4..13a2320cc 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 775b87274..c19437437 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 */