diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index 0c76d5f3c..565fc58a7 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -266,7 +266,8 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname, char buf[readUnitSize + 1]; ssize_t bytes = fread(buf, 1, readUnitSize + 1, fp); // the first time, extra bytes are read - ssize_t totalBytesRead = bytes - 1; + --bytes; + ssize_t totalBytesRead = bytes; char lastByte = buf[0]; int oldProgress = 0; @@ -280,10 +281,24 @@ int verifyChecksumFromFlash(char *mess, char *clientChecksum, char *fname, } buf[0] = lastByte; + if (totalBytesRead == bytes) { + printf("\n"); + for (int i = 0; i < 10; ++i) { + printf("[0x%x] ", buf[i]); + } + printf("\n"); + } // shift by 4 bits to the left for (int i = 0; i < bytes; ++i) { buf[i] = ((buf[i] & 0xf) << 4) + ((buf[i + 1] >> 4) & 0xf); } + if (totalBytesRead == bytes) { + printf("after the fix\n"); + for (int i = 0; i < 10; ++i) { + printf("[0x%x] ", buf[i]); + } + printf("\n"); + } lastByte = buf[bytes]; if (!MD5_Update(&c, buf, bytes)) { fclose(fp);