summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2005-07-08 17:18:35 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2005-07-08 17:18:35 (GMT)
commitf8964f5c1f29dce2c0c50e292f9e953d39ca347d (patch)
tree06c613a5aaaafce72d32cbe6ddee48b77d226a5a /src
parentc5c9b2507e22e06b04c8824813e34b504e71e281 (diff)
downloadhdf5-f8964f5c1f29dce2c0c50e292f9e953d39ca347d.zip
hdf5-f8964f5c1f29dce2c0c50e292f9e953d39ca347d.tar.gz
hdf5-f8964f5c1f29dce2c0c50e292f9e953d39ca347d.tar.bz2
[svn-r11054] Purpose: Bug fix.
Description: There was a bug in the calculating code of the Fletcher32 checksum in the library before v1.6.3. The checksum value wasn't consistent between big-endian and little-endian systems. This bug was fixed in Release 1.6.3. However, after fixing the bug, the checksum value is no longer the same as before on little-endian system. Solution: Made the library compare both the correct checksum and incorrect checksum generated from v1.6.2 or before. This makes the library be backward compatible but not forward compatible. Platforms tested: h5committest and fuss. Misc. update: Documented the forward incompatibility problem in the Known Problem section in RELEASE.txt
Diffstat (limited to 'src')
-rw-r--r--src/H5Zfletcher32.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c
index 21da7a2..c75412f 100644
--- a/src/H5Zfletcher32.c
+++ b/src/H5Zfletcher32.c
@@ -137,6 +137,9 @@ H5Z_filter_fletcher32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned U
void *outbuf = NULL; /* Pointer to new buffer */
unsigned char *src = (unsigned char*)(*buf);
uint32_t fletcher; /* Checksum value */
+ uint32_t reversed_fletcher; /* Possible wrong checksum value */
+ uint8_t c[4];
+ uint8_t tmp;
size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5Z_filter_fletcher32, 0)
@@ -159,8 +162,28 @@ H5Z_filter_fletcher32 (unsigned flags, size_t UNUSED cd_nelmts, const unsigned U
/* Compute checksum (can't fail) */
fletcher = H5Z_filter_fletcher32_compute(src,src_nbytes);
+ /* The reversed checksum. There was a bug in the calculating code of
+ * the Fletcher32 checksum in the library before v1.6.3. The checksum
+ * value wasn't consistent between big-endian and little-endian systems.
+ * This bug was fixed in Release 1.6.3. However, after fixing the bug,
+ * the checksum value is no longer the same as before on little-endian
+ * system. We'll check both the correct checksum and the wrong
+ * checksum to be consistent with Release 1.6.2 and before.
+ */
+ HDmemcpy(c, &fletcher, 4);
+
+ tmp = c[1];
+ c[1] = c[0];
+ c[0] = tmp;
+
+ tmp = c[3];
+ c[3] = c[2];
+ c[2] = tmp;
+
+ HDmemcpy(&reversed_fletcher, c, 4);
+
/* Verify computed checksum matches stored checksum */
- if(stored_fletcher != fletcher)
+ if(stored_fletcher != fletcher && stored_fletcher != reversed_fletcher)
HGOTO_ERROR(H5E_STORAGE, H5E_READERROR, 0, "data error detected by Fletcher32 checksum")
}