X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cde%2Fprograms%2Fdticon%2FfileIO.c;h=ee8fbab143a3874d9470f210571dec40193bb4f9;hb=bdc3ee7f436217a7f6c785dccdff1a8cfbb97f23;hp=4e3e80ff8c6dc68af7307515209419e01174cc14;hpb=c884521619ded86baea5e0a74c8d0d2234c232fe;p=oweals%2Fcde.git diff --git a/cde/programs/dticon/fileIO.c b/cde/programs/dticon/fileIO.c index 4e3e80ff..ee8fbab1 100644 --- a/cde/programs/dticon/fileIO.c +++ b/cde/programs/dticon/fileIO.c @@ -16,7 +16,7 @@ * details. * * You should have received a copy of the GNU Lesser General Public - * License along with these librararies and programs; if not, write + * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ @@ -54,9 +54,6 @@ ** implied warranty. ** ******************************************************************************/ -#ifdef __osf__ -#include /* for getenv() function prototype */ -#endif #include #include #include @@ -132,9 +129,9 @@ Do_FileIO( if (debug) stat_out("Entering Do_FileIO\n"); #endif - pix_ret = NULL; - shape_ret = NULL; - mask_ret = NULL; + pix_ret = 0; + shape_ret = 0; + mask_ret = 0; /* get file name */ if (SaveMeNot){ @@ -254,7 +251,7 @@ Read_File( } else /* wasn't in form ":/" so use name as is... */ { - strcpy(fname, fnameIn); + snprintf(fname, sizeof(fname), "%s", fnameIn); } /*** - if we got a NULL base_name, return FALSE ***/ @@ -277,7 +274,7 @@ Read_File( { Process_Clear(); Process_Resize(); - strcpy(last_fname, fname); + snprintf(last_fname, sizeof(last_fname), "%s", fname); ChangeTitle(); successFormat = FORMAT_NONE; return True; @@ -294,9 +291,9 @@ Read_File( XmUpdateDisplay(mainWindow); - pix_ret = NULL; - shape_ret = NULL; - mask_ret = NULL; + pix_ret = 0; + shape_ret = 0; + mask_ret = 0; xpm_ReadAttribs.valuemask = READ_FLAGS; xpm_ReadAttribs.colorsymbols = colorSymbols; xpm_ReadAttribs.numsymbols = NUM_PENS; @@ -388,7 +385,7 @@ Read_File( /*** does a suffix exist? ***/ if (suffix) { strncpy(dummy, fname, ((suffix-fname)-1)); - dummy[(int) (suffix-fname)-1] = NULL; + dummy[(int) (suffix-fname)-1] = '\0'; strcat(dummy, "_m."); strcat(dummy, suffix); #ifdef DEBUG @@ -399,8 +396,7 @@ Read_File( #endif } else { - strcpy(dummy, fname); - strcat(dummy, "_m"); + snprintf(dummy, sizeof(dummy), "%s_m", fname); } #ifdef DEBUG if (debug) @@ -412,14 +408,14 @@ Read_File( if (status == BitmapSuccess) { if ((width_ret != mask_width_ret) || (height_ret != mask_height_ret)) { XFreePixmap(dpy, mask_ret); - mask_ret = NULL; + mask_ret = 0; } } else - mask_ret = NULL; + mask_ret = 0; } - strcpy(last_fname, fname); + snprintf(last_fname, sizeof(last_fname), "%s", fname); ChangeTitle(); #ifdef DEBUG @@ -452,7 +448,7 @@ Write_File( int i, j; int mask_needed; Boolean SUN; - char *base_name, *suffix, fname[256], *tmp, *tmp2, *vend; + char *base_name, *suffix, fname[MAXPATHLEN], *tmp, *tmp2, *vend; Pixmap scratch_pix; XImage *scratch_shape, *scratch_mask; struct stat statbuf; /* Information on a file. */ @@ -478,7 +474,8 @@ Write_File( netfile = tt_host_file_netfile(fnameIn, tmp+1); localfile = tt_netfile_file(netfile); - strncpy(fname, localfile, MAXPATHLEN); + strncpy(fname, localfile, MAXPATHLEN - 1); + fname[MAXPATHLEN - 1] = 0; tmp[0] = ':'; tt_free(netfile); @@ -486,7 +483,7 @@ Write_File( } else /* wasn't in form ":/" so use name as is... */ { - strcpy(fname, fnameIn); + snprintf(fname, sizeof(fname), "%s", fnameIn); } @@ -495,7 +492,7 @@ Write_File( base_name = (base_name ? base_name + 1 : fname); } - strcpy(last_fname, fname); + snprintf(last_fname, sizeof(last_fname), "%s", fname); ChangeTitle(); #ifdef DEBUG @@ -517,7 +514,7 @@ Write_File( if (debug) Dump_AttribStruct(&xpm_WriteAttribs); #endif - status = _DtXpmWriteFileFromPixmap(dpy, fname, color_icon, NULL, + status = _DtXpmWriteFileFromPixmap(dpy, fname, color_icon, 0, &xpm_WriteAttribs); /******* @@ -550,13 +547,12 @@ Write_File( /*** THIRD, construct the mask filename ***/ if (suffix) { strncpy(dummy, fname, ((suffix-fname)-1)); - dummy[(int) (suffix-fname)-1] = NULL; + dummy[(int) (suffix-fname)-1] = '\0'; strcat(dummy, "_m."); strcat(dummy, suffix); } else { - strcpy(dummy, fname); - strcat(dummy, "_m"); + snprintf(dummy, sizeof(dummy), "%s_m", fname); } /*** FOURTH, construct XImages for the shape and mask bitmaps ***/ mask_needed = False; @@ -787,7 +783,7 @@ Display_XPMFile( icon_height = height; fileFormat = FORMAT_XPM; XmToggleButtonGadgetSetState(formatMenu_xpm_tb, True, True); -/* This line is not realy needed since an Exposed event will be generated */ +/* This line is not really needed since an Exposed event will be generated */ Repaint_Exposed_Tablet(); XDestroyImage(scratch_img); XFreePixmap(dpy, pix_ret); @@ -868,7 +864,7 @@ Display_XBMFile( icon_height = height; fileFormat = FORMAT_XBM; XmToggleButtonGadgetSetState(formatMenu_xbm_tb, True, True); -/* This line is not realy needed since an Exposed event will be generated */ +/* This line is not really needed since an Exposed event will be generated */ Repaint_Exposed_Tablet(); if (mask_ret) { XDestroyImage(test_img); @@ -976,26 +972,25 @@ SetFileIODialogInfo( void ) /* prepare to test */ tmp1 = strrchr(strOrig, '.'); - strcat(tmpStr, untitledStr); - strcat(tmpStr, ".m.pm"); + snprintf(tmpStr, sizeof(tmpStr), "%s.m.pm", untitledStr); tst=strcmp(last_fname, tmpStr); if ( tst==0 ) {/* untitled */ if ( tmp1 ) { /* previous string exists */ - if (currentTitle != SAVE_AS) strcat(newName, strOrig); - else { - strcat(newName, untitledStr); - strcat(newName, ".m.pm");} + if (currentTitle != SAVE_AS) { + snprintf(newName, sizeof(newName), "%s", strOrig); + } else { + snprintf(newName, sizeof(newName), "%s.m.pm", untitledStr); + } /* Update the FSB */ XmFileSelectionDoSearch(fileIODialog,(XmString)NULL); } else { /* First time arownd */ if (strOrig && strOrig[0]!='\0') - strcat(newName, strOrig); + snprintf(newName, sizeof(newName), "%s", strOrig); else { - strcat(newName, untitledStr); - strcat(newName, ".m.pm"); + snprintf(newName, sizeof(newName), "%s.m.pm", untitledStr); } XSync(dpy, 0); @@ -1018,7 +1013,9 @@ SetFileIODialogInfo( void ) */ c = tmp1[1]; tmp2 = strchr(tmp1, c); - strcpy(newName, tmp2); + if(tmp2) { + snprintf(newName, sizeof(newName), "%s", tmp2); + } /* make and insert the directory name */ ln = strlen(last_fname) - strlen(tmp1);