diff --git a/opal/mca/base/mca_base_component_find.c b/opal/mca/base/mca_base_component_find.c index ee0664adea..3fa25dd254 100644 --- a/opal/mca/base/mca_base_component_find.c +++ b/opal/mca/base/mca_base_component_find.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -51,10 +52,10 @@ typedef enum component_status { struct component_file_item_t { opal_list_item_t super; - char type[MCA_BASE_MAX_TYPE_NAME_LEN]; - char name[MCA_BASE_MAX_COMPONENT_NAME_LEN]; - char basename[OMPI_PATH_MAX]; - char filename[OMPI_PATH_MAX]; + char type[MCA_BASE_MAX_TYPE_NAME_LEN + 1]; + char name[MCA_BASE_MAX_COMPONENT_NAME_LEN + 1]; + char basename[OMPI_PATH_MAX + 1]; + char filename[OMPI_PATH_MAX + 1]; component_status_t status; }; typedef struct component_file_item_t component_file_item_t; @@ -71,8 +72,8 @@ typedef struct dependency_item_t dependency_item_t; static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t, NULL, NULL); struct ltfn_data_holder_t { - char type[MCA_BASE_MAX_TYPE_NAME_LEN]; - char name[MCA_BASE_MAX_COMPONENT_NAME_LEN]; + char type[MCA_BASE_MAX_TYPE_NAME_LEN + 1]; + char name[MCA_BASE_MAX_COMPONENT_NAME_LEN + 1]; }; typedef struct ltfn_data_holder_t ltfn_data_holder_t; @@ -195,6 +196,7 @@ static void find_dyn_components(const char *path, const char *type_name, opal_list_item_t *cur; strncpy(params.type, type_name, MCA_BASE_MAX_TYPE_NAME_LEN); + params.type[MCA_BASE_MAX_TYPE_NAME_LEN] = '\0'; params.name[0] = '\0'; @@ -319,10 +321,14 @@ static int save_filename(const char *filename, lt_ptr data) return OPAL_ERR_OUT_OF_RESOURCE; } strncpy(component_file->type, params->type, MCA_BASE_MAX_TYPE_NAME_LEN); + component_file->type[MCA_BASE_MAX_TYPE_NAME_LEN] = '\0'; strncpy(component_file->name, basename + prefix_len, MCA_BASE_MAX_COMPONENT_NAME_LEN); + component_file->name[MCA_BASE_MAX_COMPONENT_NAME_LEN] = '\0'; strncpy(component_file->basename, basename, OMPI_PATH_MAX); + component_file->basename[OMPI_PATH_MAX] = '\0'; strncpy(component_file->filename, filename, OMPI_PATH_MAX); + component_file->filename[OMPI_PATH_MAX] = '\0'; component_file->status = UNVISITED; opal_list_append(&found_files, (opal_list_item_t *) component_file); diff --git a/opal/mca/base/mca_base_component_repository.c b/opal/mca/base/mca_base_component_repository.c index 55b9c5a833..1bd2eb3151 100644 --- a/opal/mca/base/mca_base_component_repository.c +++ b/opal/mca/base/mca_base_component_repository.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -43,7 +44,7 @@ struct repository_item_t { opal_list_item_t super; - char ri_type[MCA_BASE_MAX_TYPE_NAME_LEN]; + char ri_type[MCA_BASE_MAX_TYPE_NAME_LEN + 1]; lt_dlhandle ri_dlhandle; const mca_base_component_t *ri_component_struct; opal_list_t ri_dependencies; @@ -154,6 +155,7 @@ int mca_base_component_repository_retain(char *type, /* Initialize the repository item */ strncpy(ri->ri_type, type, MCA_BASE_MAX_TYPE_NAME_LEN); + ri->ri_type[MCA_BASE_MAX_TYPE_NAME_LEN] = '\0'; ri->ri_dlhandle = component_handle; ri->ri_component_struct = component_struct; diff --git a/opal/mca/mca.h b/opal/mca/mca.h index a6d2fb9964..7b88ea62f1 100644 --- a/opal/mca/mca.h +++ b/opal/mca/mca.h @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -125,11 +126,11 @@ typedef int (*mca_base_query_component_fn_t)(mca_base_module_t **module, int *pr /** * Maximum length of MCA framework string names. */ -#define MCA_BASE_MAX_TYPE_NAME_LEN 32 +#define MCA_BASE_MAX_TYPE_NAME_LEN 31 /** * Maximum length of MCA component string names. */ -#define MCA_BASE_MAX_COMPONENT_NAME_LEN 64 +#define MCA_BASE_MAX_COMPONENT_NAME_LEN 63 /** * Common type for all MCA components. @@ -148,7 +149,7 @@ struct mca_base_component_t { int mca_release_version; /**< Release number of the MCA. */ - char mca_type_name[MCA_BASE_MAX_TYPE_NAME_LEN]; + char mca_type_name[MCA_BASE_MAX_TYPE_NAME_LEN + 1]; /**< String name of the framework that this component belongs to. */ int mca_type_major_version; /**< Major version number of the framework that this component @@ -160,7 +161,7 @@ struct mca_base_component_t { /**< Release version number of the framework that this component belongs to. */ - char mca_component_name[MCA_BASE_MAX_COMPONENT_NAME_LEN]; + char mca_component_name[MCA_BASE_MAX_COMPONENT_NAME_LEN + 1]; /**< This comopnent's string name. */ int mca_component_major_version; /**< This component's major version number. */