projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9289935
)
inet_cksum: big-endian fix
author
Denys Vlasenko
<vda.linux@googlemail.com>
Thu, 8 Sep 2011 08:59:26 +0000
(10:59 +0200)
committer
Denys Vlasenko
<vda.linux@googlemail.com>
Thu, 8 Sep 2011 08:59:26 +0000
(10:59 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/inet_cksum.c
patch
|
blob
|
history
diff --git
a/libbb/inet_cksum.c
b/libbb/inet_cksum.c
index 31bf8c4d959c7cf7c1d90e529c7e9527655be899..3d5dc3adf14c40f29b2ce02f51b1abf276847ca4 100644
(file)
--- a/
libbb/inet_cksum.c
+++ b/
libbb/inet_cksum.c
@@
-21,8
+21,12
@@
uint16_t FAST_FUNC inet_cksum(uint16_t *addr, int nleft)
}
/* Mop up an odd byte, if necessary */
- if (nleft)
- sum += *(uint8_t*)addr;
+ if (nleft == 1) {
+ if (BB_LITTLE_ENDIAN)
+ sum += *(uint8_t*)addr;
+ else
+ sum += *(uint8_t*)addr << 8;
+ }
/* Add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */