diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2013-07-11 22:33:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2013-07-11 22:33:35 (GMT) |
commit | 25fe312b3c500689b92cb232464d7f4801a6ba44 (patch) | |
tree | f4e3dfb77317ec4769d9d297312ef8cf68320078 /src/H5Opline.c | |
parent | ba44b1ae0835f9f52eaa8a31e5d55ef04638217e (diff) | |
download | hdf5-25fe312b3c500689b92cb232464d7f4801a6ba44.zip hdf5-25fe312b3c500689b92cb232464d7f4801a6ba44.tar.gz hdf5-25fe312b3c500689b92cb232464d7f4801a6ba44.tar.bz2 |
[svn-r23889] Description:
Merge changes from Coverity branch to trunk:
r20768:
Switch to snprintf, HDstrncat, HDstrncpy to address coverity issue 832.
r20812:
Use HDstrncpy. --gh
Tested on:
Mac OSX/64 10.8.4 (amazon) w/debug
Linux/32 2.4 (jam) w/debug
Diffstat (limited to 'src/H5Opline.c')
-rw-r--r-- | src/H5Opline.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/H5Opline.c b/src/H5Opline.c index 1a2baa0..0a0f12a 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -183,7 +183,7 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, else filter->name = filter->_name; - HDstrcpy(filter->name, (const char *)p); + HDstrncpy(filter->name, (const char *)p, actual_name_length); p += name_length; } /* end if */ @@ -375,12 +375,9 @@ H5O_pline_copy(const void *_src, void *_dst/*out*/) /* Allocate space for the filter name, or use the internal buffer */ if(namelen > H5Z_COMMON_NAME_LEN) { - dst->filter[i].name = (char *)H5MM_malloc(namelen); + dst->filter[i].name = (char *)H5MM_strdup(src->filter[i].name); if(NULL == dst->filter[i].name) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for filter name") - - /* Copy name */ - HDstrcpy(dst->filter[i].name, src->filter[i].name); } /* end if */ else dst->filter[i].name = dst->filter[i]._name; @@ -464,7 +461,7 @@ H5O_pline_size(const H5F_t UNUSED *f, const void *mesg) } /* end else */ ret_value += 2 + /*filter identification number */ - ((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ + (size_t)((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ 2 + /*flags */ 2 + /*number of client data values */ (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ @@ -633,7 +630,7 @@ H5O_pline_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, FILE *s for(i = 0; i < pline->nused; i++) { char name[32]; - sprintf(name, "Filter at position %u", (unsigned)i); + HDsnprintf(name, sizeof(name), "Filter at position %u", (unsigned)i); HDfprintf(stream, "%*s%-*s\n", indent, "", fwidth, name); HDfprintf(stream, "%*s%-*s 0x%04x\n", indent + 3, "", MAX(0, fwidth - 3), "Filter identification:", @@ -656,7 +653,7 @@ H5O_pline_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, FILE *s for(j = 0; j < pline->filter[i].cd_nelmts; j++) { char field_name[32]; - sprintf(field_name, "CD value %lu", (unsigned long)j); + HDsnprintf(field_name, sizeof(field_name), "CD value %lu", (unsigned long)j); HDfprintf(stream, "%*s%-*s %u\n", indent + 6, "", MAX(0, fwidth - 6), field_name, pline->filter[i].cd_values[j]); |