1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dticon: coverity fixes

This commit is contained in:
Peter Howkins 2018-04-28 20:33:44 +01:00
parent a135a89876
commit 3193f13070
4 changed files with 36 additions and 31 deletions

View file

@ -254,7 +254,7 @@ Read_File(
} }
else /* wasn't in form "<host>:/<path>" so use name as is... */ else /* wasn't in form "<host>:/<path>" so use name as is... */
{ {
strcpy(fname, fnameIn); snprintf(fname, sizeof(fname), "%s", fnameIn);
} }
/*** - if we got a NULL base_name, return FALSE ***/ /*** - if we got a NULL base_name, return FALSE ***/
@ -277,7 +277,7 @@ Read_File(
{ {
Process_Clear(); Process_Clear();
Process_Resize(); Process_Resize();
strcpy(last_fname, fname); snprintf(last_fname, sizeof(last_fname), "%s", fname);
ChangeTitle(); ChangeTitle();
successFormat = FORMAT_NONE; successFormat = FORMAT_NONE;
return True; return True;
@ -399,8 +399,7 @@ Read_File(
#endif #endif
} }
else { else {
strcpy(dummy, fname); snprintf(dummy, sizeof(dummy), "%s_m", fname);
strcat(dummy, "_m");
} }
#ifdef DEBUG #ifdef DEBUG
if (debug) if (debug)
@ -419,7 +418,7 @@ Read_File(
mask_ret = 0; mask_ret = 0;
} }
strcpy(last_fname, fname); snprintf(last_fname, sizeof(last_fname), "%s", fname);
ChangeTitle(); ChangeTitle();
#ifdef DEBUG #ifdef DEBUG
@ -487,7 +486,7 @@ Write_File(
} }
else /* wasn't in form "<host>:/<path>" so use name as is... */ else /* wasn't in form "<host>:/<path>" so use name as is... */
{ {
strcpy(fname, fnameIn); snprintf(fname, sizeof(fname), "%s", fnameIn);
} }
@ -496,7 +495,7 @@ Write_File(
base_name = (base_name ? base_name + 1 : fname); base_name = (base_name ? base_name + 1 : fname);
} }
strcpy(last_fname, fname); snprintf(last_fname, sizeof(last_fname), "%s", fname);
ChangeTitle(); ChangeTitle();
#ifdef DEBUG #ifdef DEBUG
@ -556,8 +555,7 @@ Write_File(
strcat(dummy, suffix); strcat(dummy, suffix);
} }
else { else {
strcpy(dummy, fname); snprintf(dummy, sizeof(dummy), "%s_m", fname);
strcat(dummy, "_m");
} }
/*** FOURTH, construct XImages for the shape and mask bitmaps ***/ /*** FOURTH, construct XImages for the shape and mask bitmaps ***/
mask_needed = False; mask_needed = False;
@ -977,26 +975,25 @@ SetFileIODialogInfo( void )
/* prepare to test */ /* prepare to test */
tmp1 = strrchr(strOrig, '.'); tmp1 = strrchr(strOrig, '.');
strcat(tmpStr, untitledStr); snprintf(tmpStr, sizeof(tmpStr), "%s.m.pm", untitledStr);
strcat(tmpStr, ".m.pm");
tst=strcmp(last_fname, tmpStr); tst=strcmp(last_fname, tmpStr);
if ( tst==0 ) {/* untitled */ if ( tst==0 ) {/* untitled */
if ( tmp1 ) { /* previous string exists */ if ( tmp1 ) { /* previous string exists */
if (currentTitle != SAVE_AS) strcat(newName, strOrig); if (currentTitle != SAVE_AS) {
else { snprintf(newName, sizeof(newName), "%s", strOrig);
strcat(newName, untitledStr); } else {
strcat(newName, ".m.pm");} snprintf(newName, sizeof(newName), "%s.m.pm", untitledStr);
}
/* Update the FSB */ /* Update the FSB */
XmFileSelectionDoSearch(fileIODialog,(XmString)NULL); XmFileSelectionDoSearch(fileIODialog,(XmString)NULL);
} }
else { /* First time arownd */ else { /* First time arownd */
if (strOrig && strOrig[0]!='\0') if (strOrig && strOrig[0]!='\0')
strcat(newName, strOrig); snprintf(newName, sizeof(newName), "%s", strOrig);
else { else {
strcat(newName, untitledStr); snprintf(newName, sizeof(newName), "%s.m.pm", untitledStr);
strcat(newName, ".m.pm");
} }
XSync(dpy, 0); XSync(dpy, 0);
@ -1019,7 +1016,9 @@ SetFileIODialogInfo( void )
*/ */
c = tmp1[1]; c = tmp1[1];
tmp2 = strchr(tmp1, c); tmp2 = strchr(tmp1, c);
strcpy(newName, tmp2); if(tmp2) {
snprintf(newName, sizeof(newName), "%s", tmp2);
}
/* make and insert the directory name */ /* make and insert the directory name */
ln = strlen(last_fname) - strlen(tmp1); ln = strlen(last_fname) - strlen(tmp1);

View file

@ -177,7 +177,7 @@ create_fileIODialog( void )
char *home; char *home;
home = getenv("HOME"); home = getenv("HOME");
sprintf(buf, "%s/%s/icons", home, DtPERSONAL_CONFIG_DIRECTORY); snprintf(buf, sizeof(buf), "%s/%s/icons", home, DtPERSONAL_CONFIG_DIRECTORY);
if (0 == stat(buf, &sbuf) && if (0 == stat(buf, &sbuf) &&
S_IFDIR & sbuf.st_mode && S_IFDIR & sbuf.st_mode &&

View file

@ -214,7 +214,9 @@ Process_Save( void )
if (tmp1) { if (tmp1) {
c = tmp1[1]; c = tmp1[1];
tmp2 = strchr(tmp1, c); tmp2 = strchr(tmp1, c);
strcpy(newName, tmp2); if(tmp2) {
snprintf(newName, sizeof(newName), "%s", tmp2);
}
} }
if (strncmp(newName, untitledStr, 8) == 0 || last_fname[0] == '\0') Process_SaveAs(); if (strncmp(newName, untitledStr, 8) == 0 || last_fname[0] == '\0') Process_SaveAs();
else else
@ -520,16 +522,13 @@ Process_Resize( void )
if ( DialogFlag == NEW ) { if ( DialogFlag == NEW ) {
strcpy(undo_file, last_fname); strcpy(undo_file, last_fname);
last_fname[0] = '\0';
SavedOnce = False; SavedOnce = False;
Backup_Icons(); /* for undo */ Backup_Icons(); /* for undo */
flag = DO_NOT_SAVE; flag = DO_NOT_SAVE;
Init_Icons(icon_width, icon_height, flag); Init_Icons(icon_width, icon_height, flag);
if (!untitledStr) if (!untitledStr)
untitledStr = GETSTR(2,20, "UNTITLED"); untitledStr = GETSTR(2,20, "UNTITLED");
strcpy(last_fname, untitledStr); snprintf(last_fname, sizeof(last_fname), "%s.m.pm", untitledStr);
strcat(last_fname, ".m.pm");
last_fname[strlen(last_fname)] = '\0';
ChangeTitle(); ChangeTitle();
Repaint_Exposed_Tablet(); Repaint_Exposed_Tablet();
Dirty = False; Dirty = False;
@ -800,8 +799,14 @@ ConvertDropName( char *objects)
tmp[0] = '\0'; tmp[0] = '\0';
if ((Boolean)XeIsLocalHostP(host)) if ((Boolean)XeIsLocalHostP(host))
{ {
char *slash = NULL;
tmp[0] = ' '; tmp[0] = ' ';
return (strdup(strchr(objects, '/'))); slash = strchr(objects, '/');
if(slash) {
return strdup(slash);
} else {
return NULL;
}
} }
/* different host... get full path name */ /* different host... get full path name */
@ -842,8 +847,7 @@ Process_DropCheckOp(
*/ */
if (transferInfo->dropData->numItems > 0) if (transferInfo->dropData->numItems > 0)
{ {
strncpy (dropFileName, transferInfo->dropData->data.files[0], snprintf(dropFileName, sizeof(dropFileName), "%s", transferInfo->dropData->data.files[0]);
MAX_FNAME);
} }
else else
dropFileName[0] = '\0'; dropFileName[0] = '\0';

View file

@ -1728,7 +1728,7 @@ Switch_FillSolids( void )
* * * *
*X11***********************************************************************/ *X11***********************************************************************/
int void
Select_New_Pen( Select_New_Pen(
int n ) int n )
{ {
@ -1755,7 +1755,7 @@ Select_New_Pen(
XmToggleButtonSetState(StaticWid[new_pen], True, False); XmToggleButtonSetState(StaticWid[new_pen], True, False);
else else
XmToggleButtonSetState(DynamicWid[new_pen], True, False); XmToggleButtonSetState(DynamicWid[new_pen], True, False);
return 0; return;
} }
/*** un-set the previous choice ***/ /*** un-set the previous choice ***/
@ -2296,7 +2296,7 @@ SaveSession( void )
{ {
tmpStr = GETSTR(16,24, "Couldn't save session to file"); tmpStr = GETSTR(16,24, "Couldn't save session to file");
tmpStr2 = (char *)XtMalloc(strlen(tmpStr) + strlen(path)+ 3); tmpStr2 = (char *)XtMalloc(strlen(tmpStr) + strlen(path)+ 3);
sprintf(tmpStr2, "%s: %s\n", tmpStr, path); snprintf(tmpStr2, sizeof(strlen(tmpStr) + strlen(path)+ 3), "%s: %s\n", tmpStr, path);
_DtSimpleErrnoError(progName, DtError, NULL, tmpStr2, NULL); _DtSimpleErrnoError(progName, DtError, NULL, tmpStr2, NULL);
XtFree(tmpStr2); XtFree(tmpStr2);
XtFree ((char *)path); XtFree ((char *)path);
@ -2358,6 +2358,8 @@ SaveSession( void )
XtFree ((char *)path); XtFree ((char *)path);
XtFree ((char *)name); XtFree ((char *)name);
close(fd);
/* Don't exit yet, SM needs time to get the new commandStr.*/ /* Don't exit yet, SM needs time to get the new commandStr.*/
} }