From f4ab6ec3a5bc5b4985b30c250d62fb860c291a96 Mon Sep 17 00:00:00 2001 From: Jerome Soumagne Date: Mon, 21 Mar 2016 15:13:51 -0500 Subject: Fix size returned from H5Rget_obj/attr/filename when buf is NULL --- src/H5R.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/H5R.c b/src/H5R.c index 9725ffe..2c386d9 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -1745,10 +1745,11 @@ H5R__get_obj_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, href_t _ref, /* Get the path name length */ UINT16DECODE(p, pathname_len); - copy_len = MIN(pathname_len, size - 1); + copy_len = pathname_len; /* Get the path name */ if (name) { + copy_len = MIN(copy_len, size - 1); HDmemcpy(name, p, copy_len); name[copy_len] = '\0'; } @@ -1884,10 +1885,11 @@ H5R__get_attr_name(H5F_t *f, href_t _ref, char *name, size_t size) /* Get the attribute name length */ UINT16DECODE(p, attr_name_len); HDassert(attr_name_len < H5R_MAX_ATTR_REF_NAME_LEN); - copy_len = MIN(attr_name_len, size - 1); + copy_len = attr_name_len; /* Get the attribute name */ if (name) { + copy_len = MIN(copy_len, size - 1); HDmemcpy(name, p, copy_len); name[copy_len] = '\0'; } @@ -1969,10 +1971,11 @@ H5R__get_file_name(href_t _ref, char *name, size_t size) /* Get the file name length */ p = (const uint8_t *)ref->ref.serial.buf; UINT16DECODE(p, filename_len); - copy_len = MIN(filename_len, size - 1); + copy_len = filename_len; /* Get the attribute name */ if (name) { + copy_len = MIN(copy_len, size - 1); HDmemcpy(name, p, copy_len); name[copy_len] = '\0'; } -- cgit v0.12