dtappbuilder: Further coverity, resource leaks, copy intofixed size buffer and dereference before null checl

This commit is contained in:
Peter Howkins
2018-04-28 02:51:10 +01:00
parent 0aa8780fa1
commit a135a89876
18 changed files with 82 additions and 44 deletions

View File

@@ -514,6 +514,8 @@ write_assign_local_vars_for_fchooser(GenCodeInfo genCodeInfo, ABObj obj)
abmfP_pattern_xmstr_var_has_value(genCodeInfo) = TRUE;
}
}
return 0;
}
static int
@@ -692,7 +694,7 @@ abmfP_strip_item_name(char *item_name)
static char new_name[MAX_NAME_SIZE];
char *p;
strcpy(new_name, item_name);
snprintf(new_name, sizeof(new_name), "%s", item_name);
p = (char *) strrchr(new_name, '_');
if (p != NULL)
*p = '\0';
@@ -2461,7 +2463,7 @@ abmfP_get_widget_parent_name(GenCodeInfo genCodeInfo, ABObj obj)
}
if (widgetParent != NULL)
{
strcpy(parentName,
snprintf(parentName, sizeof(parentName), "%s",
abmfP_get_c_name(genCodeInfo, widgetParent));
parentFound = TRUE;
}

View File

@@ -147,14 +147,12 @@ abmfP_get_c_name_global(ABObj obj)
}
fieldName = abmfP_get_c_field_name(obj);
strcpy(name, structName);
strcat(name, ".");
if (substructName != NULL)
{
strcat(name, substructName);
strcat(name, ".");
snprintf(name, sizeof(name), "%s.%s.%s", structName, substructName, fieldName);
} else {
snprintf(name, sizeof(name), "%s.%s", structName, fieldName);
}
strcat(name, fieldName);
return name;
}
@@ -275,14 +273,16 @@ abmfP_get_c_name_in_inst(ABObj obj)
}
fieldName = abmfP_get_c_field_name(obj);
strcpy(name, abmfP_instance_ptr_var_name);
strcat(name, "->");
if (substructName != NULL)
{
strcat(name, substructName);
strcat(name, ".");
snprintf(name, sizeof(name), "%s->%s.%s",
abmfP_instance_ptr_var_name,
substructName, fieldName);
} else {
snprintf(name, sizeof(name), "%s->%s",
abmfP_instance_ptr_var_name,
fieldName);
}
strcat(name, fieldName);
return name;
}
@@ -695,6 +695,7 @@ STRING
abmfP_get_c_substruct_ptr_type_name(ABObj obj)
{
static char ptrTypeName[MAX_NAME_SIZE];
char ptrTypeNameTmp[sizeof(ptrTypeName)];
STRING varName = NULL;
ABObj module = NULL;
@@ -722,11 +723,12 @@ abmfP_get_c_substruct_ptr_type_name(ABObj obj)
return NULL;
else
{
strcpy(ptrTypeName, typePrefixString);
strcat(ptrTypeName,
abmfP_capitalize_first_char(obj_get_name(module)));
strcat(ptrTypeName, abmfP_capitalize_first_char(varName));
strcat(ptrTypeName, "Items");
/* Warning: Due to abmfP_capitalize_first_char() returning a pointer
* to static data this cannot be one snprintf() */
snprintf(ptrTypeNameTmp, sizeof(ptrTypeNameTmp), "%s%s",
typePrefixString, abmfP_capitalize_first_char(obj_get_name(module)));
snprintf(ptrTypeName, sizeof(ptrTypeName), "%s%sItems",
ptrTypeNameTmp, abmfP_capitalize_first_char(varName));
cvt_ident_to_type(ptrTypeName);
}
@@ -1119,13 +1121,12 @@ ensure_unique_comp_field_names(ABObj obj)
}
{
char newObjName[1024];
*newObjName = 0;
if (compRootName != NULL)
{
strcat(newObjName, compRootName);
snprintf(newObjName, sizeof(newObjName), "%s_%s", compRootName, ext);
} else {
snprintf(newObjName, sizeof(newObjName), "_%s", ext);
}
strcat(newObjName, "_");
strcat(newObjName, ext);
util_dprintf(2, "changing field name %s -> %s\n",
util_strsafe(obj_get_name(compRoot)), newObjName);

View File

@@ -1328,11 +1328,13 @@ abmfP_get_msg_action_list(
ABObj action = NULL;
ABObj fromObj = NULL;
AB_TRAVERSAL trav;
StringList callback_funcs = strlist_create();
StringList callback_funcs = NULL;
if (!obj_is_message(msg_obj))
return NULL;
callback_funcs = strlist_create();
module = obj_get_module(msg_obj);
for (trav_open(&trav, module, AB_TRAV_ACTIONS);
(action = trav_next(&trav)) != NULL; )