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

@@ -800,8 +800,7 @@ parse_args(int argc, char *argv[], CmdlineArgs cmdline)
else
{
char fileName[MAX_PATH_SIZE];
strcpy(fileName, arg);
strcat(fileName, ".bil");
snprintf(fileName, sizeof(fileName), "%s.bil", arg);
newFile = istr_create(fileName);
}
@@ -1088,11 +1087,11 @@ load_module(ABObj module)
if (obj_get_file(module) != NULL)
{
strcpy(fileName, obj_get_file(module));
snprintf(fileName, sizeof(fileName), "%s", obj_get_file(module));
}
else
{
strcpy(fileName, obj_get_name(module));
snprintf(fileName, sizeof(fileName), "%s", obj_get_name(module));
if (!util_file_name_has_ab_extension(fileName))
{
strcat(fileName, ".bil");

View File

@@ -1351,7 +1351,7 @@ static STRING
cvt_to_obj(STRING fileName)
{
static char buf[MAXPATHLEN] = "";
strcpy(buf, fileName);
snprintf(buf, sizeof(buf), "%s", fileName);
buf[strlen(buf)-1] = 'o';
return buf;
}

View File

@@ -145,8 +145,7 @@ get_cached_msg_set(
char *project_name = obj_get_name(obj);
char proj_suffixed_name[BUFSIZ];
strcpy(proj_suffixed_name, project_name);
strcat(proj_suffixed_name, "_project");
snprintf(proj_suffixed_name, sizeof(proj_suffixed_name), "%s_project", project_name);
msg_set = MsgFile_sure_find_msg_set(msg_file, proj_suffixed_name);
prev_msg_set = msg_set;

View File

@@ -388,8 +388,7 @@ MsgFile_create(
ret_val = (MsgFile)NULL;
}
strcpy(proj_name_suffixed, project_name);
strcat(proj_name_suffixed, "_project");
snprintf(proj_name_suffixed, sizeof(proj_name_suffixed), "%s_project", project_name);
if (MsgFile_sure_find_msg_set(new_msg_file, strdup(proj_name_suffixed))
== (MsgSet)NULL)

View File

@@ -206,7 +206,7 @@ abmfP_get_c_field_name(ABObj obj)
goto epilogue;
}
strcpy(fieldNameBuf, obj_get_name(obj));
snprintf(fieldNameBuf, sizeof(fieldNameBuf), "%s", obj_get_name(obj));
abmfP_uncapitalize_first_char(fieldNameBuf);
if (substructObj != NULL)
@@ -520,8 +520,7 @@ abmfP_get_c_struct_type_name(ABObj obj)
{
return NULL;
}
strcpy(name, abmfP_get_c_struct_ptr_type_name(obj));
strcat(name, "Rec");
snprintf(name, sizeof(name), "%sRec", abmfP_get_c_struct_ptr_type_name(obj));
return_c_ident(name);
}
@@ -538,9 +537,7 @@ abmfP_get_c_struct_ptr_type_name(ABObj obj)
{
return NULL;
}
strcpy(name, typePrefixString);
strcat(name, abmfP_capitalize_first_char(varName));
strcat(name, "Info");
snprintf(name, sizeof(name), "%s%sInfo", typePrefixString, abmfP_capitalize_first_char(varName));
cvt_ident_to_type(name);
return_c_ident(name);
@@ -674,8 +671,7 @@ STRING
abmfP_get_c_substruct_field_name(ABObj obj)
{
static char fieldName[MAX_NAME_SIZE];
strcpy(fieldName, abmfP_uncapitalize_first_char(obj_get_name(obj)));
strcat(fieldName, "_items");
snprintf(fieldName, sizeof(fieldName), "%s_items", abmfP_uncapitalize_first_char(obj_get_name(obj)));
return_c_ident(fieldName);
}
@@ -690,8 +686,7 @@ abmfP_get_c_substruct_type_name(ABObj obj)
{
return NULL;
}
strcpy(typeName, ptrTypeName);
strcat(typeName, "Rec");
snprintf(typeName, sizeof(typeName), "%sRec", ptrTypeName);
return_c_ident(typeName);
}
@@ -729,7 +724,7 @@ abmfP_get_c_substruct_ptr_type_name(ABObj obj)
{
strcpy(ptrTypeName, typePrefixString);
strcat(ptrTypeName,
abmfP_capitalize_first_char(obj_get_name(module)));
abmfP_capitalize_first_char(obj_get_name(module)));
strcat(ptrTypeName, abmfP_capitalize_first_char(varName));
strcat(ptrTypeName, "Items");
cvt_ident_to_type(ptrTypeName);
@@ -751,9 +746,7 @@ abmfP_get_clear_proc_name(ABObj obj)
{
return NULL;
}
strcpy(name, ptrTypeName);
strcat(name, "_");
strcat(name, "clear");
snprintf(name, sizeof(name), "%s_clear", ptrTypeName);
return_c_ident(abmfP_uncapitalize_first_char(name));
}
@@ -823,7 +816,7 @@ abmfP_get_widget_name(ABObj obj)
name =abmfP_get_widget_name(objectObj);
if ((name != NULL) && (name != nameBuf))
{
strcpy(nameBuf, name);
snprintf(nameBuf, sizeof(nameBuf), "%s", name);
}
if ((*nameBuf) != 0)
{
@@ -861,6 +854,7 @@ STRING
abmfP_get_widget_name_for_res_file(ABObj obj)
{
static char name[MAX_NAME_SIZE];
char nameTemp[sizeof(MAX_NAME_SIZE)];
*name = 0;
assert(abmfP_parent(obj) != NULL);
@@ -912,11 +906,12 @@ abmfP_get_widget_name_for_res_file(ABObj obj)
/* we can't use abmfP_get_widget_name twice in the same printf,
* because of the static string buffer.
*/
strcpy(name, abmfP_get_app_class_name(obj));
strcat(name, "*");
strcat(name, abmfP_get_widget_name(container));
strcat(name, "*");
strcat(name, abmfP_get_widget_name(obj));
snprintf(nameTemp, sizeof(nameTemp), "%s*%s*",
abmfP_get_app_class_name(obj),
abmfP_get_widget_name(container));
snprintf(name, sizeof(name), "%s%s",
nameTemp,
abmfP_get_widget_name(obj));
}
return name;
}
@@ -1042,6 +1037,7 @@ static STRING
abmfP_build_instance_prefix(ABObj obj, STRING prefixBuf, int prefixBufSize)
{
char tmpBuf[1024] = "";
char tmpBuf2[1024] = "";
ABObj module= obj_get_module(obj);
if (module == NULL)
@@ -1050,10 +1046,12 @@ abmfP_build_instance_prefix(ABObj obj, STRING prefixBuf, int prefixBufSize)
}
else
{
strcpy(tmpBuf, identPrefixString);
strcat(tmpBuf, obj_get_name(module));
strcat(tmpBuf, "_");
strcat(tmpBuf, obj_get_name(obj));
/* Warning: Due to obj_get_name() returning a pointer to
* static data this cannot be one snprintf() */
snprintf(tmpBuf2, sizeof(tmpBuf2), "%s%s_",
identPrefixString, obj_get_name(module));
snprintf(tmpBuf, sizeof(tmpBuf), "%s%s",
tmpBuf2, obj_get_name(obj));
cvt_type_to_ident(tmpBuf, prefixBuf, prefixBufSize);
}
@@ -1070,8 +1068,7 @@ abmfP_get_c_app_root_win_name(ABObj obj)
ABObj root_window= abmfP_get_root_window(project);
*root_widget_name = 0;
strcpy(root_widget_name, abmfP_lib_get_toplevel_widget->name);
strcat(root_widget_name, "()");
snprintf(root_widget_name, sizeof(root_widget_name), "%s()", abmfP_lib_get_toplevel_widget->name);
return root_widget_name;
}
@@ -1285,8 +1282,7 @@ abmfP_get_msg_clear_proc_name(ABObj msgObj)
{
static char name[MAX_NAME_SIZE];
strcpy(name, abmfP_get_c_struct_global_name(msgObj));
strcat(name, "_initialize");
snprintf(name, sizeof(name), "%s_initialize", abmfP_get_c_struct_global_name(msgObj));
return_c_ident(name);
}

View File

@@ -471,7 +471,7 @@ write_map_window(
}
else
{
strcpy(winParentName, abmfP_get_c_name(genCodeInfo, winParent));
snprintf(winParentName, sizeof(winParentName), "%s", abmfP_get_c_name(genCodeInfo, winParent));
}
abio_printf(codeFile, "%s(%s, %s);\n",
abmfP_get_init_proc_name(window),

View File

@@ -401,7 +401,7 @@ set_up_user_type_variables(GenCodeInfo genCodeInfo, ABObj toObj)
}
else
{
strcpy(winParentName, abmfP_get_c_name(genCodeInfo, winParent));
snprintf(winParentName, sizeof(winParentName), "%s", abmfP_get_c_name(genCodeInfo, winParent));
}
/*

View File

@@ -134,7 +134,7 @@ strip_spaces_and_dots(char *mname)
static char new_name[MAXPATHLEN];
char *p;
strcpy(new_name, mname);
snprintf(new_name, sizeof(new_name), "%s", mname);
p = (char *) strrchr(new_name, '.');
if (p)
p = (char *) strrchr(p, '.');
@@ -1046,7 +1046,7 @@ write_call_user_post_create_procs(GenCodeInfo genCodeInfo, ABObj subObj)
if (targetObj == NULL)
{
strcpy(targetStructPtrName, abmfP_str_null);
snprintf(targetStructPtrName, sizeof(targetStructPtrName), "%s", abmfP_str_null);
}
else
{

View File

@@ -108,7 +108,7 @@ abmfP_capitalize_first_char(STRING str)
if (str != name) /* if we get called w/our own buffer, don't copy */
{
strcpy(name, str);
snprintf(name, sizeof(name), "%s", str);
}
name[0] = toupper(str[0]);
@@ -132,7 +132,7 @@ abmfP_uncapitalize_first_char(STRING str)
if (str != name) /* if we get called w/our own buffer, don't copy */
{
strcpy(name, str);
snprintf(name, sizeof(name), "%s", str);
}
name[0] = tolower(str[0]);
@@ -1295,6 +1295,8 @@ abmfP_obj_get_centering_type(ABObj obj)
if ((left_attach_type == AB_ATTACH_CENTER_GRIDLINE) &&
(top_attach_type == AB_ATTACH_CENTER_GRIDLINE))
return("DTB_CENTER_POSITION_BOTH");
return("DTB_CENTER_NONE");
}
BOOL
@@ -1335,6 +1337,8 @@ abmfP_obj_get_group_type(ABObj obj)
case AB_GROUP_ROWSCOLUMNS:
return("DTB_GROUP_ROWSCOLUMNS");
}
return("DTB_GROUP_NONE");
}
STRING

View File

@@ -809,7 +809,7 @@ abmfP_write_create_proc_begin(
}
int
abmfP_write_clear_proc_begin(
GenCodeInfo genCodeInfo,
ABObj obj
@@ -827,6 +827,7 @@ abmfP_write_clear_proc_begin(
}
int
abmfP_write_init_proc_decl(
GenCodeInfo genCodeInfo,
ABObj obj
@@ -857,9 +858,10 @@ abmfP_write_init_proc_decl(
NULL /* Argument name */
);
}
return 0;
}
int
abmfP_write_init_proc_begin(
GenCodeInfo genCodeInfo,
ABObj obj