diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-10-08 17:58:58 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-10-08 17:58:58 (GMT) |
commit | 48b4a56d934088305d710358405aa44f4af9eaf7 (patch) | |
tree | 3dc5d8c3073883ca93bb946f95b69bf5d9493a8f /test/ohdr.c | |
parent | c1afffec458a21b98072930d06ece03e7ba1954c (diff) | |
download | hdf5-48b4a56d934088305d710358405aa44f4af9eaf7.zip hdf5-48b4a56d934088305d710358405aa44f4af9eaf7.tar.gz hdf5-48b4a56d934088305d710358405aa44f4af9eaf7.tar.bz2 |
[svn-r7572] Purpose:
Bug fix
Description:
When too many messages were inserted into an object header, the library
had an internal pointer to the "new message" that was pointing to the incorrect
location when the array of messages was re-allocated.
In the worst case, this could cause a file to be corrupted.
Solution:
Update the internal pointer when the array is re-allocated.
Platforms tested:
FreeBSD 4.9 (sleipnir)
Too small to require h5committest
Diffstat (limited to 'test/ohdr.c')
-rw-r--r-- | test/ohdr.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/test/ohdr.c b/test/ohdr.c index c706b4b..5ddabe6 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -101,7 +101,7 @@ main(void) /* create a new message */ TESTING("message creation"); time_new = 11111111; - if (H5O_modify(&oh_ent, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if (H5O_modify(&oh_ent, H5O_MTIME_NEW_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -119,7 +119,7 @@ main(void) #endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } - if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { + if (NULL==H5O_read(&oh_ent, H5O_MTIME_NEW_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -141,7 +141,7 @@ main(void) */ TESTING("message modification"); time_new = 33333333; - if (H5O_modify(&oh_ent, H5O_MTIME_ID, 0, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if (H5O_modify(&oh_ent, H5O_MTIME_NEW_ID, 0, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -159,7 +159,7 @@ main(void) #endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } - if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { + if (NULL==H5O_read(&oh_ent, H5O_MTIME_NEW_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -182,7 +182,7 @@ main(void) */ TESTING("duplicate message creation"); time_new = 55555555; - if (H5O_modify(&oh_ent, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if (H5O_modify(&oh_ent, H5O_MTIME_NEW_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -200,7 +200,7 @@ main(void) #endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } - if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { + if (NULL==H5O_read(&oh_ent, H5O_MTIME_NEW_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -222,7 +222,7 @@ main(void) */ TESTING("duplicate message modification"); time_new = 77777777; - if (H5O_modify(&oh_ent, H5O_MTIME_ID, 1, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if (H5O_modify(&oh_ent, H5O_MTIME_NEW_ID, 1, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -240,7 +240,7 @@ main(void) #endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } - if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { + if (NULL==H5O_read(&oh_ent, H5O_MTIME_NEW_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -260,6 +260,10 @@ main(void) /* * Test creation of a bunch of messages one after another to see * what happens when the object header overflows in core. + * (Use 'old' MTIME message here, because it is large enough to be + * replaced with a continuation message (the new one is too small) + * and the library doesn't understand how to migrate more than one + * message from an object header currently - QAK - 10/8/03) */ TESTING("object header overflow in memory"); for (i=0; i<40; i++) { @@ -292,7 +296,7 @@ main(void) TESTING("object header overflow on disk"); for (i=0; i<10; i++) { time_new = (i + 1) * 1000 + 10; - if (H5O_modify(&oh_ent, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { + if (H5O_modify(&oh_ent, H5O_MTIME_NEW_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT H5Eprint(stdout); @@ -317,6 +321,15 @@ main(void) * Delete all time messages. */ TESTING("message deletion"); + if (H5O_remove(&oh_ent, H5O_MTIME_NEW_ID, H5O_ALL, H5P_DATASET_XFER_DEFAULT)<0) { + H5_FAILED(); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eprint(stdout); +#else + H5Eprint(H5E_DEFAULT, stdout); +#endif /* H5_WANT_H5_V1_6_COMPAT */ + goto error; + } if (H5O_remove(&oh_ent, H5O_MTIME_ID, H5O_ALL, H5P_DATASET_XFER_DEFAULT)<0) { H5_FAILED(); #ifdef H5_WANT_H5_V1_6_COMPAT @@ -326,6 +339,16 @@ main(void) #endif /* H5_WANT_H5_V1_6_COMPAT */ goto error; } + if (H5O_read(&oh_ent, H5O_MTIME_NEW_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { + H5_FAILED(); + puts(" H5O_read() should have failed but didn't"); +#ifdef H5_WANT_H5_V1_6_COMPAT + H5Eclear(); +#else + H5Eclear(H5E_DEFAULT); +#endif /* H5_WANT_H5_V1_6_COMPAT */ + goto error; + } if (H5O_read(&oh_ent, H5O_MTIME_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) { H5_FAILED(); puts(" H5O_read() should have failed but didn't"); |