mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
lib/checksum: fix one more thinko
When do_csum gets unaligned data, we really need to treat the first byte as an even byte, not an odd byte, because we swap the two halves later. Found by Mike's checksum-selftest module. Reported-by: Mike Frysinger <vapier.adi@gmail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
parent
20c1f641bb
commit
0a5549ed16
1 changed files with 2 additions and 2 deletions
|
@ -57,9 +57,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
|
||||||
odd = 1 & (unsigned long) buff;
|
odd = 1 & (unsigned long) buff;
|
||||||
if (odd) {
|
if (odd) {
|
||||||
#ifdef __LITTLE_ENDIAN
|
#ifdef __LITTLE_ENDIAN
|
||||||
result = *buff;
|
|
||||||
#else
|
|
||||||
result += (*buff << 8);
|
result += (*buff << 8);
|
||||||
|
#else
|
||||||
|
result = *buff;
|
||||||
#endif
|
#endif
|
||||||
len--;
|
len--;
|
||||||
buff++;
|
buff++;
|
||||||
|
|
Loading…
Reference in a new issue