summaryrefslogtreecommitdiffstats
path: root/hl/fortran/src/H5LTfc.c
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2012-03-23 04:18:59 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2012-03-23 04:18:59 (GMT)
commit213ab6eb36e398b5d0db55df002875ffcdeb4122 (patch)
tree526e07f3f28faafd10a517a043347f3fa26e4be7 /hl/fortran/src/H5LTfc.c
parent19a6303205d070f62f2579168397579001a38fe5 (diff)
downloadhdf5-213ab6eb36e398b5d0db55df002875ffcdeb4122.zip
hdf5-213ab6eb36e398b5d0db55df002875ffcdeb4122.tar.gz
hdf5-213ab6eb36e398b5d0db55df002875ffcdeb4122.tar.bz2
[svn-r22129] HDFFV-7777: Fix for removing NULL character from fortran string in h5lt_get_attribute_string_f
Fixed size +1 error in HD5f2cstring
Diffstat (limited to 'hl/fortran/src/H5LTfc.c')
-rwxr-xr-xhl/fortran/src/H5LTfc.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c
index c0b7695..674636d 100755
--- a/hl/fortran/src/H5LTfc.c
+++ b/hl/fortran/src/H5LTfc.c
@@ -17,8 +17,7 @@
#include "H5LTprivate.h"
#include "H5LTf90proto.h"
-
-
+#include "H5Eprivate.h"
/*-------------------------------------------------------------------------
* Function: H5LTmake_dataset_c
@@ -1719,13 +1718,13 @@ nh5ltget_attribute_string_c(hid_t_f *loc_id,
_fcd dsetname,
int_f *attrnamelen,
_fcd attrname,
- void *buf)
+ _fcd buf, size_t_f *buf_size)
{
int ret_value = -1;
herr_t ret;
- hid_t c_loc_id;
char *c_name = NULL;
char *c_attrname = NULL;
+ char *c_buf = NULL;
int c_namelen;
int c_attrnamelen;
@@ -1741,26 +1740,33 @@ nh5ltget_attribute_string_c(hid_t_f *loc_id,
c_attrname = (char *)HD5f2cstring(attrname, c_attrnamelen);
if (c_attrname == NULL)
goto done;
-
/*
- * Call H5LTget_attribute_int function.
- */
- c_loc_id = (hid_t)*loc_id;
-
- ret = H5LTget_attribute_string(c_loc_id,c_name,c_attrname,buf);
+ * Allocate buffer to hold C attribute string
+ */
+ if ((c_buf = HDmalloc((size_t)*buf_size + 1)) == NULL)
+ goto done;
+ /*
+ * Call H5LTget_attribute_int function.
+ */
+ ret = H5LTget_attribute_string((hid_t)*loc_id,c_name,c_attrname,c_buf);
if (ret < 0)
goto done;
- ret_value = 0;
+ /*
+ * Convert C name to FORTRAN and place it in the given buffer
+ */
+ HD5packFstring(c_buf, _fcdtocp(buf), (size_t)*buf_size);
+ ret_value = 0;
done:
if(c_name!=NULL)
free(c_name);
if(c_attrname!=NULL)
free(c_attrname);
-
+ if(c_buf!=NULL)
+ free(c_buf);
return ret_value;
}
@@ -2157,7 +2163,7 @@ nh5ltpath_valid_c(hid_t_f *loc_id,
/*
* convert FORTRAN name to C name
*/
- if( NULL == (c_path = (char *)HD5f2cstring(path, (int)*pathlen)))
+ if( NULL == (c_path = (char *)HD5f2cstring(path, (size_t)*pathlen)))
goto done;
check_object_valid = FALSE;