mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
close socket if length == 0 -- protocol violation or network error
This commit is contained in:
parent
0a794f390f
commit
8419bf2a04
1 changed files with 5 additions and 2 deletions
|
@ -103,6 +103,7 @@ bool
|
||||||
UdpQueue::handle( const AddrInfo* addr, QueueCallback cb )
|
UdpQueue::handle( const AddrInfo* addr, QueueCallback cb )
|
||||||
{
|
{
|
||||||
PartialPacket* packet;
|
PartialPacket* packet;
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
int sock = addr->socket();
|
int sock = addr->socket();
|
||||||
|
|
||||||
|
@ -122,10 +123,11 @@ UdpQueue::handle( const AddrInfo* addr, QueueCallback cb )
|
||||||
if ( packet->readSoFar() < sizeof( packet->m_len ) ) {
|
if ( packet->readSoFar() < sizeof( packet->m_len ) ) {
|
||||||
if ( packet->readAtMost( sizeof(packet->m_len) - packet->readSoFar() ) ) {
|
if ( packet->readAtMost( sizeof(packet->m_len) - packet->readSoFar() ) ) {
|
||||||
packet->m_len = ntohs(*(unsigned short*)packet->data());
|
packet->m_len = ntohs(*(unsigned short*)packet->data());
|
||||||
|
success = 0 < packet->m_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( packet->readSoFar() >= sizeof( packet->m_len ) ) {
|
if ( success && packet->readSoFar() >= sizeof( packet->m_len ) ) {
|
||||||
assert( 0 < packet->m_len );
|
assert( 0 < packet->m_len );
|
||||||
int leftToRead =
|
int leftToRead =
|
||||||
packet->m_len - (packet->readSoFar() - sizeof(packet->m_len));
|
packet->m_len - (packet->readSoFar() - sizeof(packet->m_len));
|
||||||
|
@ -137,7 +139,8 @@ UdpQueue::handle( const AddrInfo* addr, QueueCallback cb )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL == packet || packet->stillGood();
|
success = success && (NULL == packet || packet->stillGood());
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue