fixed uninitialised memoy read causing non saving of whitelist ranges

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8323 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-05-30 21:48:45 +00:00
parent 9ef5557146
commit 94649dfbfd
2 changed files with 15 additions and 5 deletions

View File

@ -693,6 +693,8 @@ bool p3BanList::loadList(std::list<RsItem*>& load)
blp.fromRsTlvBanListEntry(*it2) ;
mWhiteListedRanges[blp.addr] = blp ;
std::cerr << "Read whitelisted range " << sockaddr_storage_iptostring(blp.addr) << "/" << blp.masked_bytes << std::endl;
}
}
else

View File

@ -114,6 +114,11 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
static bool parseAddrFromQString(const QString& s,struct sockaddr_storage& addr,int& bytes )
{
QStringList lst = s.split(".") ;
bytes = 0 ;
memset(&addr,0,sizeof(sockaddr_storage)) ;
addr.ss_family = AF_INET ;
QStringList::const_iterator it = lst.begin();
bool ok ;
@ -147,7 +152,7 @@ static bool parseAddrFromQString(const QString& s,struct sockaddr_storage& addr,
((uint8_t*)&in->sin_addr.s_addr)[2] = s3 ;
((uint8_t*)&in->sin_addr.s_addr)[3] = s4 ;
return ok;
return true;
}
void ServerPage::checkIpRange(const QString& ipstr)
{
@ -558,7 +563,7 @@ bool ServerPage::removeCurrentRowFromBlackList(sockaddr_storage& collected_addr,
std::cerr <<"Cannot parse IP \"" << addr_string.toStdString() << "\"" << std::endl;
return false;
}
rsBanList->removeIpRange(collected_addr,masked_bytes,RSBANLIST_CHECKING_FLAGS_BLACKLIST);
rsBanList->removeIpRange(collected_addr,masked_bytes,RSBANLIST_TYPE_BLACKLIST);
return true ;
}
@ -587,7 +592,8 @@ void ServerPage::moveToWhiteList0()
sockaddr_storage addr ;
int bytes ;
removeCurrentRowFromBlackList(addr,bytes) ;
if(!removeCurrentRowFromBlackList(addr,bytes))
return ;
rsBanList->addIpRange(addr,0,RSBANLIST_TYPE_WHITELIST, tr("Added by you").toStdString());
}
@ -596,7 +602,8 @@ void ServerPage::moveToWhiteList1()
sockaddr_storage addr ;
int bytes ;
removeCurrentRowFromBlackList(addr,bytes) ;
if(!removeCurrentRowFromBlackList(addr,bytes))
return ;
rsBanList->addIpRange(addr,1,RSBANLIST_TYPE_WHITELIST, tr("Added by you").toStdString());
}
@ -605,7 +612,8 @@ void ServerPage::moveToWhiteList2()
sockaddr_storage addr ;
int bytes ;
removeCurrentRowFromBlackList(addr,bytes) ;
if(!removeCurrentRowFromBlackList(addr,bytes))
return ;
rsBanList->addIpRange(addr,2,RSBANLIST_TYPE_WHITELIST, tr("Added by you").toStdString());
}