From 7b2aae0911152ba79ce8a7911631a8d8f66b37f0 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Fri, 5 Feb 2021 05:02:19 +0800 Subject: [PATCH 1/9] ttsnoop: fix a segfault that occurred when clicking "Version..." in the "Snoop" menu. --- cde/programs/ttsnoop/ttsnoop_stubs.C.src | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cde/programs/ttsnoop/ttsnoop_stubs.C.src b/cde/programs/ttsnoop/ttsnoop_stubs.C.src index 0ee8414ad..8eb7b0cf1 100644 --- a/cde/programs/ttsnoop/ttsnoop_stubs.C.src +++ b/cde/programs/ttsnoop/ttsnoop_stubs.C.src @@ -1357,7 +1357,9 @@ printVersion( /*** DTB_USER_CODE_START vvv Add C code below vvv ***/ snoopStream << "ttsnoop: " << globalVersionString << endl; snoopStream << "tt_c.h: " << TT_VERSION << endl; - snoopStream << "libtt: " << _tt_lib_version << endl; + + if (_tt_lib_version) + snoopStream << "libtt: " << _tt_lib_version << endl; /*** DTB_USER_CODE_END ^^^ Add C code above ^^^ ***/ } From bb0b2838a5c8b8deb7f98747108c05ec8981d215 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Mon, 8 Feb 2021 05:47:05 +0800 Subject: [PATCH 2/9] dtappbuilder: apply graceful degradation for font loading to avoid a segmentation fault. --- cde/programs/dtappbuilder/src/ab/brws.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cde/programs/dtappbuilder/src/ab/brws.c b/cde/programs/dtappbuilder/src/ab/brws.c index 267d477cf..cbc9de320 100644 --- a/cde/programs/dtappbuilder/src/ab/brws.c +++ b/cde/programs/dtappbuilder/src/ab/brws.c @@ -1881,12 +1881,14 @@ setup_vwr_graphics( GCForeground|GCBackground|GCGraphicsExposures|GCLineWidth, &gcvalues); } - if (!ui_handle->sm_font) - { + if (!ui_handle->sm_font) ui_handle->sm_font = (XFontStruct *)XLoadQueryFont(dpy, sm_font_name); - XSetFont(dpy, ui_handle->normal_gc, ui_handle->sm_font->fid); - XSetFont(dpy, ui_handle->select_gc, ui_handle->sm_font->fid); - } + + if (!ui_handle->sm_font) + ui_handle->sm_font = (XFontStruct *)XLoadQueryFont(dpy, XmDEFAULT_FONT); + + XSetFont(dpy, ui_handle->normal_gc, ui_handle->sm_font->fid); + XSetFont(dpy, ui_handle->select_gc, ui_handle->sm_font->fid); } /* From a3d1e17c3281b394f049a9296947dc6d2967eb14 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Mon, 8 Feb 2021 07:23:10 +0800 Subject: [PATCH 3/9] dtappbuilder: fix a segmentation fault that occurred when clicking "Edit" in the "Revolving Property Editor". --- cde/programs/dtappbuilder/src/ab/prop_items.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cde/programs/dtappbuilder/src/ab/prop_items.c b/cde/programs/dtappbuilder/src/ab/prop_items.c index 0767ecdf4..ee37a28ec 100644 --- a/cde/programs/dtappbuilder/src/ab/prop_items.c +++ b/cde/programs/dtappbuilder/src/ab/prop_items.c @@ -1536,7 +1536,7 @@ set_edit_menu_stateCB( BOOL clipboard_full = False; WidgetList menu_items; int num_menu_items; - int item_key; + XtArgVal item_key; int i; listitem_exists = (pis->current_item != NULL); From 97bfb63551b37cc461c142edfbe0c63feb2e08fa Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Mon, 8 Feb 2021 07:32:01 +0800 Subject: [PATCH 4/9] dtappbuilder: fix a segmentation fault that occurred when repeating "Add Item" -> "Delete" -> "Add Item" in the "Revolving Property Editor". --- cde/programs/dtappbuilder/src/ab/prop_items.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cde/programs/dtappbuilder/src/ab/prop_items.c b/cde/programs/dtappbuilder/src/ab/prop_items.c index ee37a28ec..0b84c095c 100644 --- a/cde/programs/dtappbuilder/src/ab/prop_items.c +++ b/cde/programs/dtappbuilder/src/ab/prop_items.c @@ -1026,8 +1026,8 @@ delete_selected_item( ) { ABObj current_obj; - ABObj *iobj_list, - *new_iobj_list; + ABObj *iobj_list; + ABObj *new_iobj_list = NULL; int num_items; int select_pos; int i, j; From d7445d11790453a9dcc981e63802269226d3b096 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Mon, 8 Feb 2021 07:36:53 +0800 Subject: [PATCH 5/9] dtappbuilder: fix a segmentation fault that occurred when clicking "Edit" in the "Menu Property Editor". --- cde/programs/dtappbuilder/src/ab/pal_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cde/programs/dtappbuilder/src/ab/pal_menu.c b/cde/programs/dtappbuilder/src/ab/pal_menu.c index 079fec43c..ed9a2bc78 100644 --- a/cde/programs/dtappbuilder/src/ab/pal_menu.c +++ b/cde/programs/dtappbuilder/src/ab/pal_menu.c @@ -722,7 +722,7 @@ set_edit_menu_stateCB( BOOL clipboard_full = False; WidgetList menu_items; int num_menu_items; - int value; + XtArgVal value; AB_EDIT_TYPE item_key; int i; From 431e90db13a305cebcd3c87d660948913b98ccee Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Thu, 11 Feb 2021 03:55:20 +0800 Subject: [PATCH 6/9] csa: replace sprintf with asprintf to avoid segfaults. --- cde/lib/csa/iso8601.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/cde/lib/csa/iso8601.c b/cde/lib/csa/iso8601.c index 75b8111ac..f46ac9fa1 100644 --- a/cde/lib/csa/iso8601.c +++ b/cde/lib/csa/iso8601.c @@ -164,7 +164,7 @@ _csa_tick_to_iso8601(time_t tick, char *buf_out) { struct tm *time_str; time_t tk=tick; - char tz_orig[BUFSIZ]; + char tz_orig[BUFSIZ], *s; boolean_t orig_tzset = B_FALSE; _Xgtimeparams gmtime_buf; @@ -197,7 +197,7 @@ _csa_tick_to_iso8601(time_t tick, char *buf_out) #endif /* !linux && !CSGRC_BASED */ /* format string forces fixed width (zero-padded) fields */ - sprintf(buf_out, "%04d%02d%02dT%02d%02d%02dZ", + asprintf(&s, "%04d%02d%02dT%02d%02d%02dZ", time_str->tm_year + 1900, time_str->tm_mon + 1, time_str->tm_mday, @@ -205,7 +205,10 @@ _csa_tick_to_iso8601(time_t tick, char *buf_out) time_str->tm_min, time_str->tm_sec); - return (0); + strcpy(buf_out, s); + free(s); + + return (0); } /* @@ -258,7 +261,7 @@ _csa_iso8601_to_range(char *buf, time_t *start, time_t *end) int _csa_range_to_iso8601(time_t start, time_t end, char *buf) { - char tmpstr1[BUFSIZ], tmpstr2[BUFSIZ]; + char tmpstr1[BUFSIZ], tmpstr2[BUFSIZ], *s; /* validate: ticks must be +ve, and end can't precede start */ if ((start < 0) || (end < 0) || (end < start)) { @@ -272,11 +275,15 @@ _csa_range_to_iso8601(time_t start, time_t end, char *buf) return (-1); } - if (sprintf(buf, "%s/%s", tmpstr1, tmpstr2) < 0) { + if (asprintf(&s, "%s/%s", tmpstr1, tmpstr2) < 0) { + free(s); return (-1); } - else + else { + strcpy(buf, s); + free(s); return(0); + } } static int @@ -340,7 +347,11 @@ _csa_iso8601_to_duration(char *buf, time_t *sec) int _csa_duration_to_iso8601(time_t sec, char *buf) { - sprintf(buf, "%cPT%dS", (sec < 0) ? '-': '+', abs(sec)); - return(0); -} + char *s; + asprintf(&s, "%cPT%dS", (sec < 0) ? '-': '+', abs(sec)); + strcpy(buf, s); + free(s); + + return(0); +} From a27d05f788728d6e9ddfe1044078d3964a603afe Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Thu, 11 Feb 2021 21:01:41 +0800 Subject: [PATCH 7/9] dtcm: fix a segfault when "Drag Appt" in the dtcm_editor. --- cde/programs/dtcm/libDtCmP/cm_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cde/programs/dtcm/libDtCmP/cm_tty.c b/cde/programs/dtcm/libDtCmP/cm_tty.c index 4e20b938e..ae2401e26 100644 --- a/cde/programs/dtcm/libDtCmP/cm_tty.c +++ b/cde/programs/dtcm/libDtCmP/cm_tty.c @@ -1684,7 +1684,7 @@ attrs_to_string(CSA_attribute * attrs, int num_attrs) CSA_access_list a_ptr; char *buffer = malloc(1); char tmp_buf[MAXNAMELEN]; - int advance_time; + time_t advance_time; buffer[0] = '\0'; for (i = 0; i < num_attrs; i++) { From 49b550566730d61b7d8f03faf8821205f12be3ca Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Fri, 12 Feb 2021 18:25:25 +0800 Subject: [PATCH 8/9] dtcm: fix a segfault that occurred when opening the "Appointment List..." in the "View" menu. --- cde/programs/dtcm/dtcm/editor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cde/programs/dtcm/dtcm/editor.c b/cde/programs/dtcm/dtcm/editor.c index 0a9d7e624..193c99782 100644 --- a/cde/programs/dtcm/dtcm/editor.c +++ b/cde/programs/dtcm/dtcm/editor.c @@ -1922,6 +1922,12 @@ show_editor_view(Calendar *c, Glance glance) { Editor *e = (Editor *)c->editor; Props_pu *p = (Props_pu *)c->properties_pu; + if (get_data_version(c->cal_handle) <= CMS_VERS_2) { + backend_err_msg(c->frame, c->view->current_calendar, + CSA_E_NOT_SUPPORTED, p->xm_error_pixmap); + return; + } + if (!e->view_frame) { e->cal = c; e_build_view_popup(e); From 80f7fe773970de3c087a6518c9b48ea8c019e721 Mon Sep 17 00:00:00 2001 From: Liang Chang Date: Sat, 13 Feb 2021 02:23:01 +0800 Subject: [PATCH 9/9] dtfile: fix a segmentation fault that occurred when drag and drop file with the same name. --- cde/programs/dtfile/OverWrite.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cde/programs/dtfile/OverWrite.c b/cde/programs/dtfile/OverWrite.c index dc73bbb3b..59fb7bbab 100644 --- a/cde/programs/dtfile/OverWrite.c +++ b/cde/programs/dtfile/OverWrite.c @@ -1153,9 +1153,14 @@ create_replace_rename_dialog(Widget parent_widget, XtFree(title); - XtFree(actions.actionList[1].label); - actions.actionList[1].label = orig_label; + + if (actions.actionList[1].label != orig_label) { + XtFree(actions.actionList[1].label); + actions.actionList[1].label = orig_label; + } + actions.actionList[1].msg_num = orig_msg_num; + return; } /* end create_replace_rename_dialog */