Sfoglia il codice sorgente

add somewhat explicit uint8_t cast to crc computation to avoid errors caused by signedness mistakes

Fischer, Simon 3 anni fa
parent
commit
15cf3f2292
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  1. 2 1
      src/shellmatta_crc.c

+ 2 - 1
src/shellmatta_crc.c

@@ -125,7 +125,8 @@ uint32_t crc32Fast(char* data, uint16_t size, uint32_t* lookupTable)
 
     for (i = 0; i < size; i++)
     {
-        crcTemp = lookupTable[data[i] ^ (crcTemp & 0xff)] ^ (crcTemp >> 8);
+        uint8_t index = data[i] ^ (crcTemp & 0xff);
+        crcTemp = lookupTable[index] ^ (crcTemp >> 8);
     }
 
     return ~crcTemp;