diff --git a/cde/programs/dtcreate/CreateActionAppShell.c b/cde/programs/dtcreate/CreateActionAppShell.c index 8d62812d5..d4987e5f3 100644 --- a/cde/programs/dtcreate/CreateActionAppShell.c +++ b/cde/programs/dtcreate/CreateActionAppShell.c @@ -319,7 +319,6 @@ What do you want to do?"; "Cancel Save", questionCB_CancelSave, (char *)NULL, (XtCallbackProc)NULL); XtFree(bufPtr); - XtFree(pszActionFile); bHaveError = True; } @@ -337,6 +336,8 @@ What do you want to do?"; } } + + XtFree(pszActionFile); } static void activateCB_CA_FiletypesDelete( Widget UxWidget, @@ -540,7 +541,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) _UxParent = UxTopLevel; } - strcpy(titleBuf, GETMESSAGE(3, 10, "Create Action")); + snprintf(titleBuf, sizeof(titleBuf), "%s", GETMESSAGE(3, 10, "Create Action")); CreateActionAppShell = XtVaCreatePopupShell( "CreateActionAppShell", applicationShellWidgetClass, _UxParent, @@ -624,7 +625,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* mnemonic = GETMESSAGE(2, 21, "N"); */ - strcpy(mnemonic, GETMESSAGE(2, 21, "N")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 21, "N")); CA_MB_FileNew = XtVaCreateManagedWidget( "CA_MB_FileNew", xmPushButtonWidgetClass, CA_MB_FileOption, @@ -639,7 +640,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* mnemonic = GETMESSAGE(2, 16, "O"); */ - strcpy(mnemonic, GETMESSAGE(2, 16, "O")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 16, "O")); CA_MB_FileOpen = XtVaCreateManagedWidget( "CA_MB_FileOpen", xmPushButtonWidgetClass, CA_MB_FileOption, @@ -654,7 +655,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* mnemonic = GETMESSAGE(2, 26, "S"); */ - strcpy(mnemonic, GETMESSAGE(2, 26, "S")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 26, "S")); CA_MB_FileSave = XtVaCreateManagedWidget( "CA_MB_FileSave", xmPushButtonWidgetClass, CA_MB_FileOption, @@ -675,7 +676,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* mnemonic = GETMESSAGE(2, 31, "x"); */ - strcpy(mnemonic, GETMESSAGE(2, 31, "x")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 31, "x")); CA_MB_FileExit = XtVaCreateManagedWidget( "CA_MB_FileExit", xmPushButtonWidgetClass, CA_MB_FileOption, @@ -690,7 +691,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* mnemonic = GETMESSAGE(2, 11, "F"); */ - strcpy(mnemonic, GETMESSAGE(2, 11, "F")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 11, "F")); CA_MB_FileTop = XtVaCreateManagedWidget( "CA_MB_FileTop", xmCascadeButtonWidgetClass, CA_MenuBar, @@ -717,7 +718,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* * Creation of CA_MB_HelpOverview */ - strcpy(mnemonic, GETMESSAGE(2, 61, "v")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 61, "v")); CA_MB_HelpOverview = XtVaCreateManagedWidget( "CA_MB_HelpOverview", xmPushButtonWidgetClass, CA_MB_HelpOption, @@ -732,7 +733,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* * Creation of CA_MB_HelpTasks */ - strcpy(mnemonic, GETMESSAGE(2, 71, "T")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 71, "T")); CA_MB_HelpTasks = XtVaCreateManagedWidget( "CA_MB_HelpTasks", xmPushButtonWidgetClass, CA_MB_HelpOption, @@ -749,7 +750,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* mnemonic = GETMESSAGE(2, 66, "T"); */ - strcpy(mnemonic, GETMESSAGE(2, 66, "T")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 66, "T")); CA_MB_HelpTOC = XtVaCreateManagedWidget( "CA_MB_HelpTOC", xmPushButtonWidgetClass, CA_MB_HelpOption, @@ -761,7 +762,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* * Creation of CA_MB_HelpReference */ - strcpy(mnemonic, GETMESSAGE(2, 76, "R")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 76, "R")); CA_MB_HelpReference = XtVaCreateManagedWidget( "CA_MB_HelpReference", xmPushButtonWidgetClass, CA_MB_HelpOption, @@ -784,7 +785,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* * Creation of CA_MB_HelpUsing */ - strcpy(mnemonic, GETMESSAGE(2, 81, "U")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 81, "U")); CA_MB_HelpUsing = XtVaCreateManagedWidget( "CA_MB_HelpUsing", xmPushButtonWidgetClass, CA_MB_HelpOption, @@ -807,7 +808,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* * Creation of CA_MB_HelpAbout */ - strcpy(mnemonic, GETMESSAGE(2, 86, "A")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 86, "A")); CA_MB_HelpAbout = XtVaCreateManagedWidget( "CA_MB_HelpAbout", xmPushButtonWidgetClass, CA_MB_HelpOption, @@ -822,7 +823,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* * Creation of CA_MB_HelpTop */ - strcpy(mnemonic, GETMESSAGE(2, 54, "H")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 54, "H")); CA_MB_HelpTop = XtVaCreateManagedWidget( "CA_MB_HelpTop", xmCascadeButtonWidgetClass, CA_MenuBar, @@ -848,7 +849,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) NULL ); /* Creation of ColorMonoOption */ - strcpy(mnemonic, GETMESSAGE(2, 50, "M")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 50, "M")); ColorMonoOption = XtVaCreateManagedWidget( "ColorMonoOption", xmToggleButtonWidgetClass, CA_MB_OptionsOption, @@ -864,7 +865,7 @@ static Widget _Uxbuild_CreateActionAppShell(void) /* Creation of CA_MB_OptionTop */ - strcpy(mnemonic, GETMESSAGE(2, 36, "O")); + snprintf(mnemonic, sizeof(mnemonic), "%s", GETMESSAGE(2, 36, "O")); CA_MB_OptionTop = XtVaCreateManagedWidget( "CA_MB_OptionTop", xmCascadeButtonWidgetClass, CA_MenuBar, diff --git a/cde/programs/dtcreate/OpenFile.c b/cde/programs/dtcreate/OpenFile.c index 60f413774..cc62faffb 100644 --- a/cde/programs/dtcreate/OpenFile.c +++ b/cde/programs/dtcreate/OpenFile.c @@ -77,7 +77,7 @@ static void okCallback_OpenFile( Widget UxWidget, _UxCOpenFile *UxSaveCtx, *UxContext; XmFileSelectionBoxCallbackStruct *cbs; /*char *text;*/ - int rc; + int rc = 1; /* 1 = OpenDefinitionFile() failure */ ActionData ADTmp; UxSaveCtx = UxOpenFileContext; diff --git a/cde/programs/dtcreate/af_aux.c b/cde/programs/dtcreate/af_aux.c index 561925c9c..76c4757b6 100644 --- a/cde/programs/dtcreate/af_aux.c +++ b/cde/programs/dtcreate/af_aux.c @@ -263,7 +263,6 @@ void getAF_Icons(FiletypeData *pFiletypedata) /* Tiny Bitmap */ /***************************************************************/ if ( (pIconData->bmDirtyBit) && - (pIconData->bmFileName) && (strlen(pIconData->bmFileName)) ) { pFiletypedata->pszTinyBmIcon = XtMalloc(strlen(pIconData->bmFileName) + 1); if (pFiletypedata->pszTinyBmIcon) { diff --git a/cde/programs/dtcreate/cmncbs.c b/cde/programs/dtcreate/cmncbs.c index 7fb8a828d..5046aeebf 100644 --- a/cde/programs/dtcreate/cmncbs.c +++ b/cde/programs/dtcreate/cmncbs.c @@ -271,8 +271,7 @@ void DisplayHelpDialog(Widget wid, XtPointer client_data, XtPointer cbs) sprintf(pszTitle, "%s - %s", GETMESSAGE(3, 10, "Create Action"), GETMESSAGE(2, 53, "Help")); */ - sprintf(pszTitle, "%s - ", GETMESSAGE(3, 10, "Create Action")); - strcat(pszTitle, GETMESSAGE(2, 53, "Help")); + snprintf(pszTitle, sizeof(pszTitle), "%s - %s", GETMESSAGE(3, 10, "Create Action"), GETMESSAGE(2, 53, "Help")); XtSetArg(args[i], XmNtitle, pszTitle); i++; /***********************************************************************/ diff --git a/cde/programs/dtcreate/cmnrtns.c b/cde/programs/dtcreate/cmnrtns.c index 84a160d36..521391cf5 100644 --- a/cde/programs/dtcreate/cmnrtns.c +++ b/cde/programs/dtcreate/cmnrtns.c @@ -292,7 +292,7 @@ void load_icons (Widget wid, XtPointer client_data, /******************************************************************************/ void GetWidgetTextString (Widget wid, char **ppszText) { - char *pszTmp; + char *pszTmp = NULL; if (*ppszText) { XtFree(*ppszText); @@ -690,12 +690,12 @@ void SetIconData(Widget wid, char *pszIconFile, enum icon_size_range enumIconSiz #endif pszName = CreateIconName((char *)NULL, pszIconFile, enumIconSize, PIXMAP_EXT, FALSE); - strcpy(pmFileName, pszName); - if (pszName) XtFree(pszName); + snprintf(pmFileName, sizeof(pmFileName), "%s", pszName); + XtFree(pszName); pszName = CreateIconName((char *)NULL, pszIconFile, enumIconSize, BITMAP_EXT, FALSE); - strcpy(bmFileName, pszName); - if (pszName) XtFree(pszName); + snprintf(bmFileName, sizeof(bmFileName), "%s", pszName); + XtFree(pszName); pIconData = GetIconDataFromWid(wid); if (pIconData) { @@ -711,7 +711,6 @@ void SetIconData(Widget wid, char *pszIconFile, enum icon_size_range enumIconSiz strcpy(pIconData->pmFileName, pmFileName); if ( (pIconData->bmDirtyBit) && - (pIconData->bmFileName) && (strlen(pIconData->bmFileName)) ) { #ifdef DEBUG printf("SetIconData: unlink '%s'\n", pIconData->bmFileName); /* debug */ diff --git a/cde/programs/dtcreate/fileio.c b/cde/programs/dtcreate/fileio.c index 9ba48bea6..ba1a0b3e6 100644 --- a/cde/programs/dtcreate/fileio.c +++ b/cde/programs/dtcreate/fileio.c @@ -614,7 +614,9 @@ ushort WriteDefinitionFile(char *pszFile, ActionData *pAD) } SetCookie(fp); if (fp) fclose(fp); - chmod(pszFile, 0644); + if(pszFile) { + chmod(pszFile, 0644); + } return(0); } @@ -655,7 +657,7 @@ ushort WriteActionFile(ActionData *pAD) /***************************************************************************/ /* Open action file for writing. */ /***************************************************************************/ - if (pszFile && (fp = fopen(pszFile, "w")) == NULL) { + if (pszFile == NULL || (fp = fopen(pszFile, "w")) == NULL) { #ifdef DEBUG printf("Can not open file.\n"); /* debug */ #endif @@ -694,7 +696,7 @@ ushort WriteActionFile(ActionData *pAD) fprintf(fp, "echo \"Common Desktop Environment Dt action\"\n"); fprintf(fp, "\n"); - if (fp) fclose(fp); + fclose(fp); chmod(pszFile, 0755); return(0); } @@ -746,7 +748,7 @@ int OpenDefinitionFile(char *pszFile, ActionData *pAD) { FILE *fp = (FILE *)NULL; - int rc; + int rc = 1; char *msgPtr, *fmtPtr, *errPtr; /***************************************************************************/ @@ -789,10 +791,11 @@ int OpenDefinitionFile(char *pszFile, ActionData *pAD) sprintf(errPtr, fmtPtr, msgPtr, pszFile); display_error_message(CreateActionAppShell, errPtr); XtFree(errPtr); + fclose(fp); return(1); } } - if (fp) fclose(fp); + fclose(fp); return(rc); } diff --git a/cde/programs/dtcreate/icon_selection_dialog.c b/cde/programs/dtcreate/icon_selection_dialog.c index 79b32f982..c0bff51f4 100644 --- a/cde/programs/dtcreate/icon_selection_dialog.c +++ b/cde/programs/dtcreate/icon_selection_dialog.c @@ -790,7 +790,7 @@ void update_container_contents (char *filter) XmeFlushIconFileCache(NULL); for (lcv = 0; lcv < count; lcv++) { - sprintf (iconfile, "%s%s", path, filelist[lcv]->d_name); + snprintf(iconfile, sizeof(iconfile), "%s%s", path, filelist[lcv]->d_name); ptr = strstr(filelist[lcv]->d_name, ".m."); if (ptr) { *ptr = '\0'; @@ -813,7 +813,7 @@ void update_container_contents (char *filter) /* This is the empty directory case */ /******************************************************************/ } else { - strcpy(iconfile, GETMESSAGE(11, 60, "[Empty]")); + snprintf(iconfile, sizeof(iconfile), "%s", GETMESSAGE(11, 60, "[Empty]")); xmstring = XmStringCreateLocalized(iconfile); XtVaSetValues ((Widget) icons_in_container[0], XmNstring, xmstring, @@ -841,6 +841,7 @@ void update_container_contents (char *filter) } XtManageChild (icon_scrolled_container); + free(path); return; } @@ -1261,6 +1262,7 @@ static void defaultActionCB_dir_scrolled_list( Widget UxWidget, filter = (char *)XmStringToText (listcb->item); apply_filter (filter); /* XtManageChild (icon_scrolled_win); */ + free(filter); } UxIcon_selection_dialogContext = UxSaveCtx; } diff --git a/cde/programs/dtcreate/main.c b/cde/programs/dtcreate/main.c index b9deaa567..aae400b98 100644 --- a/cde/programs/dtcreate/main.c +++ b/cde/programs/dtcreate/main.c @@ -514,7 +514,6 @@ void RemoveTmpIconFiles( void ) unlink(maskFile); } if ( (IconDataList[i]->bmDirtyBit) && - (IconDataList[i]->bmFileName) && (strlen(IconDataList[i]->bmFileName)) ) { #ifdef DEBUG printf("RemoveTmpIconFiles: unlink '%s'\n", IconDataList[i]->bmFileName); /* debug */ @@ -863,7 +862,7 @@ Tt_callback_action IconEdit_tt_handler( Tt_message m, Tt_pattern p ) if (tmp) { tmp1 = strstr(tmp, "};"); } - sprintf(tmpbuf, "%s_m", tmpIconFile); + snprintf(tmpbuf, sizeof(tmpbuf), "%s_m", tmpIconFile); if (tmp1) { tmp1 += 2; /* Go one char past the ";" */ #ifdef DEBUG @@ -1067,6 +1066,7 @@ void UxDoEditPixmap(Widget wid, char *fname) display_error_message(XtParent(wid), errPtr); XtFree(errPtr); XtFree(mname); + if (fd1 > -1) close(fd1); return; } else { /***************************************/ @@ -1103,6 +1103,8 @@ void UxDoEditPixmap(Widget wid, char *fname) XtFree(errPtr); if (mname) XtFree(mname); XtFree((char *) buffer); + if (fd1 > -1) close(fd1); + if (fd2 > -1) close(fd2); return; } if (lenFile2) { @@ -1127,11 +1129,13 @@ void UxDoEditPixmap(Widget wid, char *fname) XtFree(errPtr); XtFree((char *) buffer); if (mname) XtFree(mname); + if (fd1 > -1) close(fd1); + if (fd2 > -1) close(fd2); return; } } - if (fd1 > -1) close(fd1); - if (fd2 > -1) close(fd2); + if (fd1 > -1) close(fd1); fd1 = -1; + if (fd2 > -1) close(fd2); fd2 = -1; #ifdef DEBUG printf("final buffer = '%s'\n", buffer); /* debug */ @@ -1171,6 +1175,9 @@ void UxDoEditPixmap(Widget wid, char *fname) TurnOnHourGlassAllWindows(); ttRc = tt_message_send( m ); DieFromToolTalkError( UxTopLevel, "tt_message_send", ttRc ); + + if (fd1 > -1) close(fd1); + if (fd2 > -1) close(fd2); } #endif /* __TOOLTALK */ diff --git a/cde/programs/dtcreate/parser.c b/cde/programs/dtcreate/parser.c index 400834fa9..13e855fea 100644 --- a/cde/programs/dtcreate/parser.c +++ b/cde/programs/dtcreate/parser.c @@ -647,6 +647,7 @@ FiletypeData **ppFiletypeData,**ppnewFiletypeData; ppFiletypeData[nfiletypes] = 0; /* return number of filetypes */ *nftypes = nfiletypes+1; + free(execstr); return ppFiletypeData; } @@ -707,8 +708,7 @@ GetKeywordValuePairs(char *s, int *id, int table) if (!args[1]) { int szArgs1 = strlen(s) + 1; - if(s) - args[1] = (char *)malloc (szArgs1); + args[1] = (char *)malloc (szArgs1); if (!args[1]) { if(args[0]) @@ -881,7 +881,7 @@ int done=FALSE, argfound=FALSE,promptfound=FALSE; continue; } } - else if (s1 && *s1) + else if (*s1) { strcat(exec_args[0],s1); if(argbuf) { free(argbuf); argbuf = NULL; } @@ -1018,8 +1018,10 @@ char *s1,*tmp,*s2,buf[10],*cts; pFtD->fsFlags|=CA_FT_CNTLONG; else if ( !strcmp(buf,"short") ) pFtD->fsFlags|=CA_FT_CNTSHORT; - else + else { + free(cts); return (-1); + } } while( *tmp && isspace(*tmp) ) tmp++; s2=tmp;