{
static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
NULL, NULL};
- char view_number[5];
+ char view_number[11];
char number[5];
- char workspaceNumber[5];
+ char workspaceNumber[11];
int fd;
Atom * ws_presence = NULL;
char * workspace_name=NULL;
char * full_path = NULL;
Boolean status=False;
char * temp = NULL;
- char wsNum[5];
- char dialogNum[5];
+ char wsNum[11];
+ char dialogNum[11];
int num_sec_help_dialogs;
int i;
int j;
XrmRepresentation rep_type;
XrmValue value;
static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
- char view_number[5];
+ char view_number[11];
DialogData * dialog_data;
FileMgrData * file_mgr_data;
char * workspaces;
if (FileSysType(statbuf.st_dev) < 0) /* Root user and nfs */
#endif
{
+ int fd = -1;
char *tmpfile;
tmpfile = tempnam(parentdir,"dtfile");
if (!tmpfile)
return -1;
- if (creat(tmpfile,O_RDONLY) < 0) /* Create a temporary file */
+ if ((fd = creat(tmpfile,O_RDONLY)) < 0) /* Create a temporary file */
{
free(tmpfile);
return -1;
}
+ close(fd);
if (remove(tmpfile) < 0) /* Delete the created file */
{
free(tmpfile);
if (first_file)
{
/* check for write permission in this directory */
- if (CheckAccess(destinationPath, W_OK|X_OK) < 0)
+ if (CheckAccess(destinationPath, W_OK|X_OK) < 0) {
+ closedir(dirp);
return -1;
+ }
/* append a '/' to the end of directory name */
fnamep = destinationPath + strlen(destinationPath);
}
if(stat(target,&stattar) >= 0) /* Target exists */
{
- if(CheckDeletePermission(localdir,target))
+ if(CheckDeletePermission(localdir,target)) {
+ free(localdir);
return ((int)False);
- else
+ } else {
+ free(localdir);
return SKIP_FILE;
+ }
}
}
/* Save the name of the source directory in order to truncate the pathname */
/* displayed as the copy proceeds ... see function UpdateStatus. */
- strcpy(G_source_dir,source);
+ snprintf(G_source_dir, sizeof(G_source_dir), "%s", source);
tsource = (char * )get_path(source);
ttarget = (char * )get_path(target);
/* get file name */
p = strrchr(fname, '/');
if (p && p > fname)
- strcpy(deP->name, p + 1);
+ snprintf(deP->name, sizeof(deP->name), "%s", p + 1);
else
- strcpy(deP->name, fname);
+ snprintf(deP->name, sizeof(deP->name), "%s", fname);
/* assume everything is fine */
*op = 0;
}
/* copy dirname to file name buffer */
- strcpy(fname, dirname);
+ snprintf(fname, sizeof(fname), "%s", dirname);
fnP = fname + strlen(fname);
*fnP++ = '/';
else if (SP->keepold) {
char newname[1024];
- strcpy(newname, fname);
- strcat(newname, SP->keepold);
+ snprintf(newname, sizeof(newname), "%s%s", fname, SP->keepold);
fsMove(fname, newname, 1, &rc);
} else if ((fP->ftype & ft_isdir) && !(fP->ftype & ft_islnk)) {
/* save pointer to params; copy source & target names */
SP = p;
- strcpy(sbuf, SP->source);
- strcpy(tbuf, SP->target);
+ snprintf(sbuf, sizeof(sbuf), "%s", SP->source);
+ snprintf(tbuf, sizeof(tbuf), "%s", SP->target);
/* get info about the source */
sP = GetDirEntry(sbuf, &op, &rc);
****************************************************************************
************************************<+>*************************************/
+#include <limits.h>
+
/* Macros */
#define MAX_PATH PATH_MAX
extern Widget G_toggle_main;
extern Widget G_toggle_error;
-extern char G_rename_oldname[];
-extern char G_source_dir[];
+extern char G_rename_oldname[MAX_PATH];
+extern char G_source_dir[MAX_PATH];
extern int G_move;
extern int G_do_copy;
extern int G_pause_copy;
return errno;
/* prepare source name */
- strcpy(srcname, sourceP);
+ snprintf(srcname, sizeof(srcname), "%s", sourceP);
srclen = strlen(srcname);
if (srcname[srclen - 1] != '/')
srcname[srclen++] = '/';
/* first check if we have write permission in the source directory */
char dir[1024], *p;
- strcpy(dir, sourceP);
+ snprintf(dir, sizeof(dir), "%s", sourceP);
p = strrchr(dir, '/');
if (p == 0)
strcpy(dir, ".");
/* save the target name for possible rename in ok_callback */
- strcpy(G_rename_oldname,tname);
+ snprintf(G_rename_oldname, sizeof(G_rename_oldname), "%s", tname);
if (G_move)