mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 00:36:34 +02:00
Merge pull request #6684 from birarda/read-type-assert
fix reading of empty or malformed packets
This commit is contained in:
commit
3da5cf1fe5
1 changed files with 10 additions and 4 deletions
|
@ -236,8 +236,14 @@ void Socket::readPendingDatagrams() {
|
||||||
auto buffer = std::unique_ptr<char[]>(new char[packetSizeWithHeader]);
|
auto buffer = std::unique_ptr<char[]>(new char[packetSizeWithHeader]);
|
||||||
|
|
||||||
// pull the datagram
|
// pull the datagram
|
||||||
_udpSocket.readDatagram(buffer.get(), packetSizeWithHeader,
|
auto sizeRead = _udpSocket.readDatagram(buffer.get(), packetSizeWithHeader,
|
||||||
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
||||||
|
|
||||||
|
if (sizeRead <= 0) {
|
||||||
|
// we either didn't pull anything for this packet or there was an error reading (this seems to trigger
|
||||||
|
// on windows even if there's not a packet available)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto it = _unfilteredHandlers.find(senderSockAddr);
|
auto it = _unfilteredHandlers.find(senderSockAddr);
|
||||||
|
|
||||||
|
@ -248,7 +254,7 @@ void Socket::readPendingDatagrams() {
|
||||||
it->second(std::move(basePacket));
|
it->second(std::move(basePacket));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if this was a control packet or a data packet
|
// check if this was a control packet or a data packet
|
||||||
|
@ -276,7 +282,7 @@ void Socket::readPendingDatagrams() {
|
||||||
packet->getDataSize(),
|
packet->getDataSize(),
|
||||||
packet->getPayloadSize())) {
|
packet->getPayloadSize())) {
|
||||||
// the connection indicated that we should not continue processing this packet
|
// the connection indicated that we should not continue processing this packet
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue