summaryrefslogtreecommitdiffstats
path: root/src/H5Oattr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2014-02-20 21:29:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2014-02-20 21:29:26 (GMT)
commit1e36b5a348415501aa8eb992fd57c09d834900cd (patch)
tree9a423be6cbe38eed62268779703258972fb94191 /src/H5Oattr.c
parentb30e37ea78a85c9a2e3abda7fddaabb636935b1c (diff)
downloadhdf5-1e36b5a348415501aa8eb992fd57c09d834900cd.zip
hdf5-1e36b5a348415501aa8eb992fd57c09d834900cd.tar.gz
hdf5-1e36b5a348415501aa8eb992fd57c09d834900cd.tar.bz2
[svn-r24726] Description:
Revert some earlier usage of strncpy, which was incorrect. Bring Coverity changes from branch back to trunk: r20821: Use HDstrncpy. --gh (Fixed already, with strdup) r20822: (Not merged, incorrect use of HDstrncpy()) r20823: (Not merged, incorrect use of HDstrncpy()) r20824: Maintenance: Bug fix: addressed CID 666. Value stored at *expression_len should be used in the call to HD5packFstring to avoid overflow (and unnecessary arithmetic calculation and casting) r20825: Issue 642: Added check for error and handler with print to stderr and exit. r20826: Undo revision 20818, as that issue has already been fixed in the 1.8 branch and trunk (but not coverity branch) r20827: (Not merged, incorrect use of HDstrncpy()) r20828: Use HDstrncpy. --gh (Corrected use of strncpy()) r20829: Check return of H5Lget_val(print_udata->fid, path, targbuf, linfo->u.val_size + 1, H5P_DEFAULT) and if error set trgbuf[0] to 0. Check if H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &objname) was successful and allow print. Otherwise filename and objname are not created. (init those to NULL) r20830: resolved coverity issues 939, 940, 941, 944, and 947. all were complaints about use of sprintf, and in all cases, the buffers used were large enough for all eventualities. Resolved issue by replacing calls to sprintf with calls to snprintf. r20831: Maintenance: Addressed CID 852 Replaced sprintf with snprintf r20832: Purpose: Fix valgrind issues with hl/examples/ex_image2 Description: Modified hl/examples/ex_image2 to free global "gbuf" before exit. Tested on: Mac OSX/64 10.9.1 (amaon) w/C++, FORTRAN & Threadsafety (too minor to require h5committest)
Diffstat (limited to 'src/H5Oattr.c')
-rw-r--r--src/H5Oattr.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index b8e6b32..2269bd3 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -793,7 +793,7 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
{
const H5A_t *mesg = (const H5A_t *)_mesg;
const char *s; /* Temporary string pointer */
- char buf[256]; /* Temporary string buffer */
+ char buf[128]; /* Temporary string buffer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -804,7 +804,7 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
HDassert(indent >= 0);
HDassert(fwidth >= 0);
- fprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth,
"Name:",
mesg->shared->name);
switch(mesg->shared->encoding) {
@@ -830,17 +830,17 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
case H5T_CSET_RESERVED_13:
case H5T_CSET_RESERVED_14:
case H5T_CSET_RESERVED_15:
- sprintf(buf, "H5T_CSET_RESERVED_%d", (int)(mesg->shared->encoding));
+ HDsnprintf(buf, sizeof(buf), "H5T_CSET_RESERVED_%d", (int)(mesg->shared->encoding));
s = buf;
break;
case H5T_CSET_ERROR:
default:
- sprintf(buf, "Unknown character set: %d", (int)(mesg->shared->encoding));
+ HDsnprintf(buf, sizeof(buf), "Unknown character set: %d", (int)(mesg->shared->encoding));
s = buf;
break;
} /* end switch */
- fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Character Set of Name:",
s);
HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth,
@@ -856,18 +856,18 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
"Creation Index:",
(unsigned)mesg->shared->crt_idx);
- fprintf(stream, "%*sDatatype...\n", indent, "");
- fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0,fwidth-3),
+ HDfprintf(stream, "%*sDatatype...\n", indent, "");
+ HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0,fwidth - 3),
"Encoded Size:",
(unsigned long)(mesg->shared->dt_size));
if((H5O_MSG_DTYPE->debug)(f, dxpl_id, mesg->shared->dt, stream, indent + 3, MAX(0, fwidth - 3)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display datatype message info")
- fprintf(stream, "%*sDataspace...\n", indent, "");
- fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth - 3),
+ HDfprintf(stream, "%*sDataspace...\n", indent, "");
+ HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3),
"Encoded Size:",
(unsigned long)(mesg->shared->ds_size));
- if(H5S_debug(f, dxpl_id, mesg->shared->ds, stream, indent+3, MAX(0, fwidth - 3)) < 0)
+ if(H5S_debug(f, dxpl_id, mesg->shared->ds, stream, indent + 3, MAX(0, fwidth - 3)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to display dataspace message info")
done: