Skip to content

Commit

Permalink
[netif] fix byteorder in mld packet parsing (#463)
Browse files Browse the repository at this point in the history
It was not causing crach or missing multicast packets since there is a
packet length guard and only one record is sent each time.
  • Loading branch information
gjc13 authored Mar 18, 2020
1 parent 5157992 commit b161410
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/TunnelIPv6Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ TunnelIPv6Interface::processMLDMonitorFD(void)
hdr = reinterpret_cast<MLDv2Header *>(buffer);
offset = sizeof(MLDv2Header);

for (size_t i = 0; i < hdr->mNumRecords && offset < bufferLen; i++) {
for (size_t i = 0; i < ntohs(hdr->mNumRecords) && offset < bufferLen; i++) {
if (bufferLen - offset >= sizeof(MLDv2Record)) {
MLDv2Record *record = reinterpret_cast<MLDv2Record *>(&buffer[offset]);

Expand All @@ -463,7 +463,7 @@ TunnelIPv6Interface::processMLDMonitorFD(void)
}
}

offset += sizeof(MLDv2Record) + sizeof(in6_addr) * record->mNumSources;
offset += sizeof(MLDv2Record) + sizeof(in6_addr) * ntohs(record->mNumSources);
}
}

Expand Down

0 comments on commit b161410

Please sign in to comment.