We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 43ca398 commit 8bc2d00Copy full SHA for 8bc2d00
test/util/socket_util.cc
@@ -900,14 +900,14 @@ TestAddress V6MulticastLinkLocalAllRouters() {
900
uint16_t Checksum(uint16_t* buf, ssize_t buf_size) {
901
// Add up the 16-bit values in the buffer.
902
uint32_t total = 0;
903
- for (unsigned int i = 0; i < buf_size; i += sizeof(*buf)) {
+ for (unsigned int i = 0; i < buf_size - 1; i += sizeof(*buf)) {
904
total += *buf;
905
buf++;
906
}
907
908
// If buf has an odd size, add the remaining byte.
909
if (buf_size % 2) {
910
- total += *(reinterpret_cast<unsigned char*>(buf) - 1);
+ total += *(reinterpret_cast<unsigned char*>(buf));
911
912
913
// This carries any bits past the lower 16 until everything fits in 16 bits.
0 commit comments