1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

dtfile: batch coverity fixes

This commit is contained in:
Peter Howkins 2018-04-28 23:12:04 +01:00
parent 17a80f4933
commit 399c1e08c3
7 changed files with 30 additions and 22 deletions

View file

@ -2584,9 +2584,9 @@ SaveSession(
{
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;
@ -2991,8 +2991,8 @@ RestoreSession(
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;
@ -3226,7 +3226,7 @@ LoadViews (
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;

View file

@ -4168,15 +4168,17 @@ CheckDeletePermission(
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);
@ -4232,8 +4234,10 @@ CheckDeletePermissionRecur(
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);
@ -4307,10 +4311,13 @@ RestoreObject(
}
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;
}
}
}

View file

@ -484,7 +484,7 @@ create_copydir_dialog(
/* 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);

View file

@ -254,9 +254,9 @@ GetDirEntry(char *fname, FileOp *op, int *rc)
/* 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;
@ -321,7 +321,7 @@ GetDir(char *dirname, PatternList *xl, PatternList *sl, DirEntry **listPP)
}
/* copy dirname to file name buffer */
strcpy(fname, dirname);
snprintf(fname, sizeof(fname), "%s", dirname);
fnP = fname + strlen(fname);
*fnP++ = '/';
@ -410,8 +410,7 @@ doUnlink(char *fname, DirEntry *fP, int confirm)
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)) {
@ -941,8 +940,8 @@ SyncDirectory(SyncParams *p)
/* 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);

View file

@ -38,6 +38,8 @@
****************************************************************************
************************************<+>*************************************/
#include <limits.h>
/* Macros */
#define MAX_PATH PATH_MAX
@ -93,8 +95,8 @@ extern Widget G_rename_text;
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;

View file

@ -366,7 +366,7 @@ EmptyDir(char *sourceP, int rm, int force)
return errno;
/* prepare source name */
strcpy(srcname, sourceP);
snprintf(srcname, sizeof(srcname), "%s", sourceP);
srclen = strlen(srcname);
if (srcname[srclen - 1] != '/')
srcname[srclen++] = '/';
@ -486,7 +486,7 @@ fsMove(char *sourceP, char *targetP, int replace, int *rcP)
/* 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, ".");

View file

@ -278,7 +278,7 @@ create_overwrite_dialog(
/* 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)