summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorScott Wegner <swegner@hdfgroup.org>2008-05-12 20:51:36 (GMT)
committerScott Wegner <swegner@hdfgroup.org>2008-05-12 20:51:36 (GMT)
commitf7b35b78f4c0f03261614c5a22a1fe089f9944ea (patch)
treefe0aac567f321564625bb7fa3571a8ed3354bdbf /src
parent24bce352512ce1b61c285690b2d949b20d9c8551 (diff)
downloadhdf5-f7b35b78f4c0f03261614c5a22a1fe089f9944ea.zip
hdf5-f7b35b78f4c0f03261614c5a22a1fe089f9944ea.tar.gz
hdf5-f7b35b78f4c0f03261614c5a22a1fe089f9944ea.tar.bz2
[svn-r14984] Purpose: Fix bug in H5G_get_name_by_addr where buffer size is less than size of name
Description: Backport of the bug found earlier today in HDF5 1.9. The H5G_get_name_by_addr function makes a call to strncat writes an extra null byte when the buffer is smaller than the dataset name. Also, comment out 2 lines that are no longer necessary because of the fix. Tested: kagiso
Diffstat (limited to 'src')
-rw-r--r--src/H5Gname.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/H5Gname.c b/src/H5Gname.c
index 78c1ea0..9a00fae 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -1242,10 +1242,12 @@ H5G_get_name_by_addr(hid_t file, hid_t dxpl_id, const H5G_entry_t *loc,
HDstrcpy(name, "/");
/* Append the rest of the path */
- /* (less one character, for the initial path separator) */
- HDstrncat(name, udata.path, (size - 1));
- if((size_t)ret_value >= size)
- name[size - 1] = '\0';
+ /* (less two characters, for the initial path separator, */
+ /* and because strncat appends a null byte) */
+ HDstrncat(name, udata.path, (size - 2));
+ // Unnecessary, because strncat will always set the last byte null.
+ // if((size_t)ret_value >= size)
+ // name[size - 1] = '\0';
} /* end if */
} /* end if */
else