diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-10-27 02:12:02 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-10-27 02:12:02 (GMT) |
commit | c274ffe1c9bdfa256459213cab1ece7f566b9620 (patch) | |
tree | a08fa12cc07b4b8f8471bbcfd8d94e34a82d03c5 /src | |
parent | a75d43be95aa7009b5a20306eedb08c0a734a18e (diff) | |
download | hdf5-c274ffe1c9bdfa256459213cab1ece7f566b9620.zip hdf5-c274ffe1c9bdfa256459213cab1ece7f566b9620.tar.gz hdf5-c274ffe1c9bdfa256459213cab1ece7f566b9620.tar.bz2 |
[svn-r9466] Purpose:
Bug fix
Description:
Clean up potential buffer overflow in strncpy()
Platforms tested:
FreeBSD 4.10 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Pdxpl.c | 12 | ||||
-rw-r--r-- | src/H5Ztrans.c | 1 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 5941a19..49fece6 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -80,6 +80,7 @@ done: FUNC_LEAVE_API(ret_value); } + /*------------------------------------------------------------------------- * Function: H5Pget_data_transform * @@ -136,11 +137,9 @@ ssize_t H5Pget_data_transform(hid_t plist_id, char* expression /*out*/, size_t s len = HDstrlen(pexp); if(expression) { - /* sanity check */ - if(size > len) - size = len; - - HDstrncpy(expression, pexp, size); + HDstrncpy(expression, pexp, MIN(len+1,size)); + if(len >= size) + expression[size-1]='\0'; } ret_value = (ssize_t)len; @@ -155,9 +154,6 @@ done: FUNC_LEAVE_API(ret_value); } - - - /*------------------------------------------------------------------------- * Function: H5Pset_buffer diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 437d79e..d14af45 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -1594,7 +1594,6 @@ H5Z_xform_extract_xform_str(const H5Z_data_xform_t *data_xform_prop) /* There should be no way that these can be NULL since the function * that calls this one checks to make sure they aren't before * pasing them */ - assert(exp); assert(data_xform_prop); ret_value = data_xform_prop->xform_exp; |