Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for a segfault when H5Pset_fapl_log is passed an invalid fapl ID #607

Merged
merged 25 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ba9deae
Committing clang-format changes
github-actions[bot] Mar 19, 2021
00f9750
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 21, 2021
e997283
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 22, 2021
3eac585
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 23, 2021
71643b7
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
d242911
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
bc70f95
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
3d7ad8e
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
aeb16b7
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 26, 2021
765cb5b
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 27, 2021
18401fc
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 29, 2021
222242c
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 29, 2021
8d0cafa
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 30, 2021
d3694d1
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 2, 2021
1c7bcc2
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 15, 2021
70551e3
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 16, 2021
2dfc7db
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 20, 2021
71d2fbf
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 21, 2021
c8925f8
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 22, 2021
dd3e970
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Apr 22, 2021
bb61990
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 23, 2021
2c2b368
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 25, 2021
be2ada6
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 27, 2021
439f3a8
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 28, 2021
f2b33a0
Fixes an issue where H5Pset_fapl_log sefaults when passed an invalid
derobins Apr 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,19 @@ New Features

Library:
--------
- H5Pset_fapl_log() no longer crashes when passed an invalid fapl ID

When passed an invalid fapl ID, H5Pset_fapl_log() would usually
segfault when attempting to free an uninitialized pointer in the error
handling code. This behavior is more common in release builds or
when the memory sanitization checks were not selected as a build
option.

The pointer is now correctly initialized and the API call now
produces a normal HDF5 error when fed an invalid fapl ID.

(DER - 2021/04/28, HDFFV-11240)

- HSYS_GOTO_ERROR now emits the results of GetLastError() on Windows

HSYS_GOTO_ERROR is an internal macro that is used to produce error
Expand Down
7 changes: 5 additions & 2 deletions src/H5FDlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,15 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*sULz", fapl_id, logfile, flags, buf_size);

/* Do this first, so that we don't try to free a wild pointer if
* H5P_object_verify() fails.
*/
HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t));

/* Check arguments */
if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")

HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t));

/* Duplicate the log file string
* A little wasteful, since this string will just be copied later, but
* passing it in as a pointer sets off a chain of impossible-to-resolve
Expand Down
13 changes: 12 additions & 1 deletion test/vfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1867,12 +1867,23 @@ test_log(void)
hsize_t file_size = 0;
unsigned int flags = H5FD_LOG_ALL;
size_t buf_size = 4 * KB;
herr_t ret = SUCCEED;

TESTING("LOG file driver");

/* Set property list and file name for log driver. */
if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
TEST_ERROR;

/* Make sure calling with an invalid fapl doesn't crash */
H5E_BEGIN_TRY
{
ret = H5Pset_fapl_log(H5I_INVALID_HID, LOG_FILENAME, 0, 0);
}
H5E_END_TRY;
if (SUCCEED == ret)
TEST_ERROR;

/* Set property list and file name for log driver. */
if (H5Pset_fapl_log(fapl, LOG_FILENAME, flags, buf_size) < 0)
TEST_ERROR;
h5_fixname(FILENAME[6], fapl, filename, sizeof filename);
Expand Down