mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
Device can't be 'alreadyHere' if has hostID of 0 since the only way a
device gets registered involves giving it a non-0 hostID. Fixes array OOB access.
This commit is contained in:
parent
80f66d1df7
commit
fe51d19c2e
1 changed files with 14 additions and 12 deletions
|
@ -379,18 +379,20 @@ CookieRef::AlreadyHere( HostID hid, unsigned short seed, const AddrInfo* addr,
|
|||
hid, seed, seed, addr->socket() );
|
||||
bool here = false;
|
||||
|
||||
RWWriteLock rwl( &m_socketsRWLock );
|
||||
HostRec* hr = m_sockets[hid-1];
|
||||
if ( !!hr ) {
|
||||
if ( seed != hr->m_seed ) {
|
||||
*spotTaken = true;
|
||||
} else if ( addr->equals( hr->m_addr ) ) {
|
||||
here = true; /* dup packet */
|
||||
} else {
|
||||
logf( XW_LOGINFO, "%s: hids match; nuking existing record "
|
||||
"for socket b/c assumed closed", __func__ );
|
||||
delete hr;
|
||||
m_sockets[hid-1] = NULL;
|
||||
if ( HOST_ID_NONE != hid ) {
|
||||
RWWriteLock rwl( &m_socketsRWLock );
|
||||
HostRec* hr = m_sockets[hid-1];
|
||||
if ( !!hr ) {
|
||||
if ( seed != hr->m_seed ) {
|
||||
*spotTaken = true;
|
||||
} else if ( addr->equals( hr->m_addr ) ) {
|
||||
here = true; /* dup packet */
|
||||
} else {
|
||||
logf( XW_LOGINFO, "%s: hids match; nuking existing record "
|
||||
"for socket b/c assumed closed", __func__ );
|
||||
delete hr;
|
||||
m_sockets[hid-1] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue