From f8964f5c1f29dce2c0c50e292f9e953d39ca347d Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Fri, 8 Jul 2005 12:18:35 -0500 Subject: [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 --- release_docs/RELEASE.txt | 16 +++++++++------- src/H5Zfletcher32.c | 25 ++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 90f4ba3..0c1e298 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -732,13 +732,15 @@ Linux 2.4 IA64 Intel y n y n y y y Known Problems ============== -* The dataset created with the v1.6.2 library can't be read with the v1.6.3 - library or after when Fletcher32 EDC(filter) is enabled. 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. SLU - 2005/6/30 +* The dataset created or rewritten with the v1.6.3 library or after can't + be read with the v1.6.2 library or before when Fletcher32 EDC(filter) is + enabled. 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. The library release + after 1.6.4 can still read the dataset created or rewritten with the library + of v1.6.2 or before. SLU - 2005/6/30 * For the version 6(6.02 and 6.04) of Portland Group compiler on AMD Opteron processor, there's a bug in the compiler for optimization(-O2). The library failed in several tests but all related to multi driver. The problem has 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") } -- cgit v0.12