From: William Schaub Date: Sat, 11 Aug 2012 08:02:17 +0000 (-0400) Subject: dtcreate: fix exit with TT_ERR_PTYPE and fix several sprintf related segfaults. X-Git-Tag: 2.2.0b~83^2~27 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=562da5af1b7f24a42a3361285565038e8c369694;p=oweals%2Fcde.git dtcreate: fix exit with TT_ERR_PTYPE and fix several sprintf related segfaults. --- diff --git a/cde/programs/dtcreate/AddFiletype.c b/cde/programs/dtcreate/AddFiletype.c index 8d70b2a2..7df5bb2e 100644 --- a/cde/programs/dtcreate/AddFiletype.c +++ b/cde/programs/dtcreate/AddFiletype.c @@ -261,6 +261,7 @@ static Widget _Uxbuild_AddFiletype(void) char *pre, *suf, *title; XmString emptyString; + size_t len; #define TIGHTNESS 20 #define ICON_MIN_HEIGHT 83 @@ -276,8 +277,9 @@ static Widget _Uxbuild_AddFiletype(void) pre = GETMESSAGE(3, 10, "Create Action"); suf = GETMESSAGE(7, 10, "Add Datatype"); - title = XtMalloc(strlen(pre) + strlen(suf) + 2); - sprintf(title, "%s - %s", pre, suf); + len = strlen(pre) + strlen(suf) + 4; + title = XtMalloc(len); + snprintf(title,len - 1, "%s - %s", pre, suf); _UxParent = XtVaCreatePopupShell( "AddFiletype_shell", xmDialogShellWidgetClass, _UxParent, diff --git a/cde/programs/dtcreate/CreateActionAppShell.c b/cde/programs/dtcreate/CreateActionAppShell.c index 5396a8c7..8558ba5e 100644 --- a/cde/programs/dtcreate/CreateActionAppShell.c +++ b/cde/programs/dtcreate/CreateActionAppShell.c @@ -345,6 +345,7 @@ static void activateCB_CA_FiletypesDelete( Widget UxWidget, int cnt; Boolean bFound; char *msgPtr1, *msgPtr2, *fmtPtr, *errPtr; + size_t len; /**************************************************************************/ /* Determine the filetypes to delete and delete them. */ @@ -411,9 +412,9 @@ static void activateCB_CA_FiletypesDelete( Widget UxWidget, msgPtr2 = XtNewString(GETMESSAGE(5, 125, "Please select the Datatype you would like to Delete.")); fmtPtr = "%s\n%s"; - errPtr = XtMalloc((strlen(msgPtr1) + strlen(msgPtr2) + - strlen(fmtPtr) + 1) * sizeof(char)); - sprintf(errPtr, fmtPtr, msgPtr1, msgPtr2); + len = (strlen(msgPtr1) + strlen(msgPtr2) + strlen(fmtPtr) + 2); + errPtr = XtMalloc(len); + snprintf(errPtr,len - 1, fmtPtr, msgPtr1, msgPtr2); XtFree(msgPtr2); XtFree(msgPtr1); display_error_message(CreateActionAppShell, errPtr); diff --git a/cde/programs/dtcreate/ca_aux.c b/cde/programs/dtcreate/ca_aux.c index afd105a2..74f08e15 100644 --- a/cde/programs/dtcreate/ca_aux.c +++ b/cde/programs/dtcreate/ca_aux.c @@ -849,6 +849,7 @@ void activateCB_add_filetype (Widget wid, XtPointer client_data, char *ptr; char tmpbuf[50]; char *pre, *suf, *title; + size_t len; if (!CreateActionAppShellCheckFields()) { @@ -893,8 +894,9 @@ void activateCB_add_filetype (Widget wid, XtPointer client_data, pre = GETMESSAGE(3, 10, "Create Action"); suf = GETMESSAGE(7, 10, "Add Datatype"); - title = XtMalloc(strlen(pre) + strlen(suf) + 2); - sprintf(title, "%s - %s", pre, suf); + len = strlen(pre) + strlen(suf) + 4; + title = XtMalloc(len); + snprintf(title,len - 1,"%s - %s", pre, suf); XtVaSetValues (AddFiletype, RES_CONVERT (XmNdialogTitle, title ), @@ -924,11 +926,13 @@ void activateCB_edit_filetype (Widget wid, XtPointer client_data, int selecteditem; char *msgPtr1, *msgPtr2, *fmtPtr, *errPtr; char *pre, *suf, *title; + size_t len; pre = GETMESSAGE(3, 10, "Create Action"); suf = GETMESSAGE(7, 11, "Edit Datatype"); - title = XtMalloc(strlen(pre) + strlen(suf) + 2); - sprintf(title, "%s - %s", pre, suf); + len = strlen(pre) + strlen(suf) + 4; + title = XtMalloc(len); + snprintf(title,len - 1, "%s - %s", pre, suf); /**************************************************************************/ /* Determine the selected list item. */ @@ -959,9 +963,10 @@ void activateCB_edit_filetype (Widget wid, XtPointer client_data, msgPtr2 = XtNewString(GETMESSAGE(5, 130, "Please select the Datatype you would like to Edit.")); fmtPtr = "%s\n%s"; - errPtr = XtMalloc((strlen(msgPtr1) + strlen(msgPtr2) + - strlen(fmtPtr) + 1) * sizeof(char)); - sprintf(errPtr, fmtPtr, msgPtr1, msgPtr2); + len = (strlen(msgPtr1) + strlen(msgPtr2) + + strlen(fmtPtr) + 3); + errPtr = XtMalloc(len); + snprintf(errPtr,len - 1, fmtPtr, msgPtr1, msgPtr2); XtFree(msgPtr2); XtFree(msgPtr1); display_error_message(CreateActionAppShell, errPtr); diff --git a/cde/programs/dtcreate/main.c b/cde/programs/dtcreate/main.c index 168cd885..1b56e3ff 100644 --- a/cde/programs/dtcreate/main.c +++ b/cde/programs/dtcreate/main.c @@ -548,6 +548,9 @@ DieFromToolTalkError(Widget parent, char *errfmt, Tt_status status) if (! tt_is_err(status)) return; statmsg = tt_status_message(status); + /* Solaris dtcreate ignores this so we should too */ + if(!strncmp("TT_ERR_PTYPE",statmsg,12)) + return; errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + 2); sprintf(errmsg, errfmt, statmsg);