dtappbuilder: Coverity fixes for mising return value and copy into fixed size buffer

This commit is contained in:
Peter Howkins
2018-04-26 01:36:02 +01:00
parent 4007d3a460
commit bb9eef427f
29 changed files with 81 additions and 82 deletions

View File

@@ -287,9 +287,7 @@ abobj_list_obj_reparented(
if (obj_get_parent(obj) == NULL)
{
module = obj_get_name(obj_get_module(info->old_parent));
strcpy(full_name, module);
strcat(full_name, " :: ");
strcat(full_name, obj_get_name(obj));
snprintf(full_name, sizeof(full_name), "%s :: %s", module, obj_get_name(obj));
name = full_name;
}
else

View File

@@ -321,7 +321,7 @@ init_ab(ABInitProcInfo init_info)
user_file_name = init_info->argv[1];
}
strcpy(file_name, user_file_name);
snprintf(file_name, sizeof(file_name), "%s", user_file_name);
if (!util_file_exists(file_name))
{
*file_name = 0;

View File

@@ -891,7 +891,7 @@ menu_editCB(
/* store off original clipboard menu name and temporarily
* set it to a dummy string.
*/
strcpy(namebuf, obj_get_name(pms->clipboard_menu));
snprintf(namebuf, sizeof(namebuf), "%s", obj_get_name(pms->clipboard_menu));
obj_set_name(pms->clipboard_menu, "MENU_DUMMY");
/* duplicate clipboard menu & menu-items */

View File

@@ -202,8 +202,7 @@ build_export_menu(
/* Use the name of the module as the string
* for the dynamic menu.
*/
strcpy(name, obj_get_name(module));
strcat(name, "...");
snprintf(name, sizeof(name), "%s...", obj_get_name(module));
label = XmStringCreateLocalized(name);
mpb = XtVaCreateManagedWidget(name,
xmPushButtonWidgetClass,

View File

@@ -184,8 +184,7 @@ projP_show_save_as_bil_chooser(
XtFree(title);
textf = XmFileSelectionBoxGetChild(AB_generic_chooser,
XmDIALOG_TEXT);
strcpy(init_name, (char *)obj_get_name(obj));
strcat(init_name, ".bil");
snprintf(init_name, sizeof(init_name), "%s.bil", (char *)obj_get_name(obj));
XmTextFieldSetString(textf, init_name);
XtManageChild(AB_generic_chooser);
ui_win_front(AB_generic_chooser);

View File

@@ -458,8 +458,7 @@ proj_show_save_proj_as_chooser(
XtFree(title);
textf = XmFileSelectionBoxGetChild(AB_generic_chooser,
XmDIALOG_TEXT);
strcpy(init_name, (char *)obj_get_name(proj_get_project()));
strcat(init_name, ".bip");
snprintf(init_name, sizeof(init_name), "%s.bip", (char *)obj_get_name(proj_get_project()));
XmTextFieldSetString(textf, init_name);
XtManageChild(AB_generic_chooser);
ui_win_front(AB_generic_chooser);
@@ -644,12 +643,12 @@ save_proj_as_bip(
/* Save the old project directory before chdir'ing
* to the new one.
*/
strcpy(old_proj_dir, ab_get_cur_dir());
snprintf(old_proj_dir, sizeof(old_proj_dir), "%s", ab_get_cur_dir());
/*
* Compose the project file name.
*/
strcpy(new_filename, file);
snprintf(new_filename, sizeof(new_filename), "%s", file);
abio_expand_bil_proj_path(new_filename);
/*
@@ -969,8 +968,7 @@ proj_show_export_bil_chooser(
XtFree(title);
textf = XmFileSelectionBoxGetChild(AB_generic_chooser,
XmDIALOG_TEXT);
strcpy(init_name, (char *)obj_get_name(obj));
strcat(init_name, ".bil");
snprintf(init_name, sizeof(init_name), "%s.bil", (char *)obj_get_name(obj));
XmTextFieldSetString(textf, init_name);
XtManageChild(AB_generic_chooser);
ui_win_front(AB_generic_chooser);
@@ -1464,7 +1462,7 @@ proj_save_exploded(
*/
if ((obj_get_file(module) == NULL) || encap_file)
{
strcpy(tmp_path, obj_get_name(module));
snprintf(tmp_path, sizeof(tmp_path), "%s", obj_get_name(module));
abio_expand_file(tmp_path, mod_exp_file);
if ( !util_file_exists(mod_exp_file) )
{
@@ -2043,7 +2041,7 @@ save_as_encap(
filename = XmTextFieldGetString(textf);
if (util_strempty(filename))
strcpy(init_name, (char *)obj_get_name(proj_get_project()));
snprintf(init_name, sizeof(init_name), "%s", (char *)obj_get_name(proj_get_project()));
else
util_check_name(filename, init_name);
@@ -2089,7 +2087,7 @@ export_format_changed(
** exported. If a filename is specified, it might be either .bil or .uil.
*/
if (util_strempty(filename))
strcpy(init_name, (char *)obj_get_name(module_obj));
snprintf(init_name, sizeof(init_name), "%s", (char *)obj_get_name(module_obj));
else
proj_get_file_basename(filename, init_name);
@@ -2122,7 +2120,7 @@ save_proj_as_bix(
ab_set_busy_cursor(TRUE);
*bix_file = 0;
strcpy(bix_file, file);
snprintf(bix_file, sizeof(bix_file), "%s", file);
if( abio_expand_bil_encapsulated_path(bix_file) != -1 )
{
if( !util_file_exists(bix_file) )

View File

@@ -788,7 +788,7 @@ prop_colorfield_init(
/* Determine whether this is a foreground or background color field
* and store the corresponding color-default in user-data.
*/
strcpy(swatch_name, XtName(swatch));
snprintf(swatch_name, sizeof(swatch_name), "%s", XtName(swatch));
if (strstr(swatch_name, "bg"))
default_pix = WhitePixelOfScreen(XtScreen(swatch));
else
@@ -805,7 +805,7 @@ prop_colorfield_init(
XmNrecomputeSize, (XtArgVal)False,
NULL);
strcpy(swatch_name, XtName(swatch));
snprintf(swatch_name, sizeof(swatch_name), "%s", XtName(swatch));
/* Setup Prop Sheet changebar mechanism */
propP_changebar_init(changebar, menubutton);
@@ -1987,7 +1987,7 @@ prop_graphic_filename_ok(
}
else
{
strcpy(filebase, filename);
snprintf(filebase, sizeof(filebase), "%s", filename);
/* Look to see if user typed in the full filename for the Graphic.
* If so, strip off the extension and mark stripped to be True.
*/

View File

@@ -874,7 +874,7 @@ prop_item_get_namebase(
switch(iobj->label_type)
{
case AB_LABEL_SEPARATOR:
strcpy(namebuf, obj_get_name(iobj));
snprintf(namebuf, sizeof(namebuf), "%s", obj_get_name(iobj));
starts = strstr(namebuf, SeparatorNamebase);
namebase = strtok(starts, "_");
break;

View File

@@ -279,6 +279,8 @@ ui_list_replace_item_prefix(
new_xmitem_array[0] = NULL;
}
}
return OK;
}