Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/util/socket_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -900,14 +900,14 @@ TestAddress V6MulticastLinkLocalAllRouters() {
uint16_t Checksum(uint16_t* buf, ssize_t buf_size) {
// Add up the 16-bit values in the buffer.
uint32_t total = 0;
for (unsigned int i = 0; i < buf_size; i += sizeof(*buf)) {
for (unsigned int i = 0; i < buf_size - 1; i += sizeof(*buf)) {
total += *buf;
buf++;
}

// If buf has an odd size, add the remaining byte.
if (buf_size % 2) {
total += *(reinterpret_cast<unsigned char*>(buf) - 1);
total += *(reinterpret_cast<unsigned char*>(buf));
}

// This carries any bits past the lower 16 until everything fits in 16 bits.
Expand Down
Loading