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:
parent
17a80f4933
commit
399c1e08c3
7 changed files with 30 additions and 22 deletions
|
@ -2584,9 +2584,9 @@ SaveSession(
|
||||||
{
|
{
|
||||||
static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
|
static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
|
||||||
NULL, NULL};
|
NULL, NULL};
|
||||||
char view_number[5];
|
char view_number[11];
|
||||||
char number[5];
|
char number[5];
|
||||||
char workspaceNumber[5];
|
char workspaceNumber[11];
|
||||||
int fd;
|
int fd;
|
||||||
Atom * ws_presence = NULL;
|
Atom * ws_presence = NULL;
|
||||||
char * workspace_name=NULL;
|
char * workspace_name=NULL;
|
||||||
|
@ -2991,8 +2991,8 @@ RestoreSession(
|
||||||
char * full_path = NULL;
|
char * full_path = NULL;
|
||||||
Boolean status=False;
|
Boolean status=False;
|
||||||
char * temp = NULL;
|
char * temp = NULL;
|
||||||
char wsNum[5];
|
char wsNum[11];
|
||||||
char dialogNum[5];
|
char dialogNum[11];
|
||||||
int num_sec_help_dialogs;
|
int num_sec_help_dialogs;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -3226,7 +3226,7 @@ LoadViews (
|
||||||
XrmRepresentation rep_type;
|
XrmRepresentation rep_type;
|
||||||
XrmValue value;
|
XrmValue value;
|
||||||
static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
|
static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
|
||||||
char view_number[5];
|
char view_number[11];
|
||||||
DialogData * dialog_data;
|
DialogData * dialog_data;
|
||||||
FileMgrData * file_mgr_data;
|
FileMgrData * file_mgr_data;
|
||||||
char * workspaces;
|
char * workspaces;
|
||||||
|
|
|
@ -4168,15 +4168,17 @@ CheckDeletePermission(
|
||||||
if (FileSysType(statbuf.st_dev) < 0) /* Root user and nfs */
|
if (FileSysType(statbuf.st_dev) < 0) /* Root user and nfs */
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
int fd = -1;
|
||||||
char *tmpfile;
|
char *tmpfile;
|
||||||
tmpfile = tempnam(parentdir,"dtfile");
|
tmpfile = tempnam(parentdir,"dtfile");
|
||||||
if (!tmpfile)
|
if (!tmpfile)
|
||||||
return -1;
|
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);
|
free(tmpfile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
close(fd);
|
||||||
if (remove(tmpfile) < 0) /* Delete the created file */
|
if (remove(tmpfile) < 0) /* Delete the created file */
|
||||||
{
|
{
|
||||||
free(tmpfile);
|
free(tmpfile);
|
||||||
|
@ -4232,8 +4234,10 @@ CheckDeletePermissionRecur(
|
||||||
if (first_file)
|
if (first_file)
|
||||||
{
|
{
|
||||||
/* check for write permission in this directory */
|
/* 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;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* append a '/' to the end of directory name */
|
/* append a '/' to the end of directory name */
|
||||||
fnamep = destinationPath + strlen(destinationPath);
|
fnamep = destinationPath + strlen(destinationPath);
|
||||||
|
@ -4307,10 +4311,13 @@ RestoreObject(
|
||||||
}
|
}
|
||||||
if(stat(target,&stattar) >= 0) /* Target exists */
|
if(stat(target,&stattar) >= 0) /* Target exists */
|
||||||
{
|
{
|
||||||
if(CheckDeletePermission(localdir,target))
|
if(CheckDeletePermission(localdir,target)) {
|
||||||
|
free(localdir);
|
||||||
return ((int)False);
|
return ((int)False);
|
||||||
else
|
} else {
|
||||||
|
free(localdir);
|
||||||
return SKIP_FILE;
|
return SKIP_FILE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -484,7 +484,7 @@ create_copydir_dialog(
|
||||||
|
|
||||||
/* Save the name of the source directory in order to truncate the pathname */
|
/* Save the name of the source directory in order to truncate the pathname */
|
||||||
/* displayed as the copy proceeds ... see function UpdateStatus. */
|
/* 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);
|
tsource = (char * )get_path(source);
|
||||||
ttarget = (char * )get_path(target);
|
ttarget = (char * )get_path(target);
|
||||||
|
|
|
@ -254,9 +254,9 @@ GetDirEntry(char *fname, FileOp *op, int *rc)
|
||||||
/* get file name */
|
/* get file name */
|
||||||
p = strrchr(fname, '/');
|
p = strrchr(fname, '/');
|
||||||
if (p && p > fname)
|
if (p && p > fname)
|
||||||
strcpy(deP->name, p + 1);
|
snprintf(deP->name, sizeof(deP->name), "%s", p + 1);
|
||||||
else
|
else
|
||||||
strcpy(deP->name, fname);
|
snprintf(deP->name, sizeof(deP->name), "%s", fname);
|
||||||
|
|
||||||
/* assume everything is fine */
|
/* assume everything is fine */
|
||||||
*op = 0;
|
*op = 0;
|
||||||
|
@ -321,7 +321,7 @@ GetDir(char *dirname, PatternList *xl, PatternList *sl, DirEntry **listPP)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy dirname to file name buffer */
|
/* copy dirname to file name buffer */
|
||||||
strcpy(fname, dirname);
|
snprintf(fname, sizeof(fname), "%s", dirname);
|
||||||
fnP = fname + strlen(fname);
|
fnP = fname + strlen(fname);
|
||||||
*fnP++ = '/';
|
*fnP++ = '/';
|
||||||
|
|
||||||
|
@ -410,8 +410,7 @@ doUnlink(char *fname, DirEntry *fP, int confirm)
|
||||||
else if (SP->keepold) {
|
else if (SP->keepold) {
|
||||||
char newname[1024];
|
char newname[1024];
|
||||||
|
|
||||||
strcpy(newname, fname);
|
snprintf(newname, sizeof(newname), "%s%s", fname, SP->keepold);
|
||||||
strcat(newname, SP->keepold);
|
|
||||||
fsMove(fname, newname, 1, &rc);
|
fsMove(fname, newname, 1, &rc);
|
||||||
|
|
||||||
} else if ((fP->ftype & ft_isdir) && !(fP->ftype & ft_islnk)) {
|
} 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 */
|
/* save pointer to params; copy source & target names */
|
||||||
SP = p;
|
SP = p;
|
||||||
strcpy(sbuf, SP->source);
|
snprintf(sbuf, sizeof(sbuf), "%s", SP->source);
|
||||||
strcpy(tbuf, SP->target);
|
snprintf(tbuf, sizeof(tbuf), "%s", SP->target);
|
||||||
|
|
||||||
/* get info about the source */
|
/* get info about the source */
|
||||||
sP = GetDirEntry(sbuf, &op, &rc);
|
sP = GetDirEntry(sbuf, &op, &rc);
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
************************************<+>*************************************/
|
************************************<+>*************************************/
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
/* Macros */
|
/* Macros */
|
||||||
#define MAX_PATH PATH_MAX
|
#define MAX_PATH PATH_MAX
|
||||||
|
|
||||||
|
@ -93,8 +95,8 @@ extern Widget G_rename_text;
|
||||||
extern Widget G_toggle_main;
|
extern Widget G_toggle_main;
|
||||||
extern Widget G_toggle_error;
|
extern Widget G_toggle_error;
|
||||||
|
|
||||||
extern char G_rename_oldname[];
|
extern char G_rename_oldname[MAX_PATH];
|
||||||
extern char G_source_dir[];
|
extern char G_source_dir[MAX_PATH];
|
||||||
extern int G_move;
|
extern int G_move;
|
||||||
extern int G_do_copy;
|
extern int G_do_copy;
|
||||||
extern int G_pause_copy;
|
extern int G_pause_copy;
|
||||||
|
|
|
@ -366,7 +366,7 @@ EmptyDir(char *sourceP, int rm, int force)
|
||||||
return errno;
|
return errno;
|
||||||
|
|
||||||
/* prepare source name */
|
/* prepare source name */
|
||||||
strcpy(srcname, sourceP);
|
snprintf(srcname, sizeof(srcname), "%s", sourceP);
|
||||||
srclen = strlen(srcname);
|
srclen = strlen(srcname);
|
||||||
if (srcname[srclen - 1] != '/')
|
if (srcname[srclen - 1] != '/')
|
||||||
srcname[srclen++] = '/';
|
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 */
|
/* first check if we have write permission in the source directory */
|
||||||
char dir[1024], *p;
|
char dir[1024], *p;
|
||||||
|
|
||||||
strcpy(dir, sourceP);
|
snprintf(dir, sizeof(dir), "%s", sourceP);
|
||||||
p = strrchr(dir, '/');
|
p = strrchr(dir, '/');
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
strcpy(dir, ".");
|
strcpy(dir, ".");
|
||||||
|
|
|
@ -278,7 +278,7 @@ create_overwrite_dialog(
|
||||||
|
|
||||||
|
|
||||||
/* save the target name for possible rename in ok_callback */
|
/* 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)
|
if (G_move)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue