mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed crashes with poping ConfCertDialog with incomplete certificate
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5429 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a9d19528a0
commit
2b20ab7fca
@ -71,11 +71,15 @@ std::string RsCertificate::toStdString() const
|
||||
unsigned char *buf = new unsigned char[BS] ;
|
||||
|
||||
addPacket( CERTIFICATE_PTAG_PGP_SECTION , binary_pgp_key , binary_pgp_key_size , buf, p, BS ) ;
|
||||
|
||||
if(!only_pgp)
|
||||
{
|
||||
addPacket( CERTIFICATE_PTAG_EXTIPANDPORT_SECTION, ipv4_external_ip_and_port , 6 , buf, p, BS ) ;
|
||||
addPacket( CERTIFICATE_PTAG_LOCIPANDPORT_SECTION, ipv4_internal_ip_and_port , 6 , buf, p, BS ) ;
|
||||
addPacket( CERTIFICATE_PTAG_DNS_SECTION , (unsigned char *)dns_name.c_str() , dns_name.length() , buf, p, BS ) ;
|
||||
addPacket( CERTIFICATE_PTAG_NAME_SECTION , (unsigned char *)location_name.c_str() ,location_name.length() , buf, p, BS ) ;
|
||||
addPacket( CERTIFICATE_PTAG_SSLID_SECTION , location_id.toByteArray() ,location_id.SIZE_IN_BYTES, buf, p, BS ) ;
|
||||
}
|
||||
|
||||
std::string out_string ;
|
||||
|
||||
@ -116,13 +120,13 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
|
||||
if(binary_pgp_block_size == 0 || binary_pgp_block == NULL)
|
||||
throw std::runtime_error("Cannot init a certificate with a void key block.") ;
|
||||
|
||||
if(Detail.isOnlyGPGdetail)
|
||||
throw std::runtime_error("Cannot init a certificate with a RsPeerDetails with only GPG details.") ;
|
||||
|
||||
binary_pgp_key = new unsigned char[binary_pgp_block_size] ;
|
||||
memcpy(binary_pgp_key,binary_pgp_block,binary_pgp_block_size) ;
|
||||
binary_pgp_key_size = binary_pgp_block_size ;
|
||||
|
||||
if(!Detail.isOnlyGPGdetail)
|
||||
{
|
||||
only_pgp = false ;
|
||||
location_id = SSLIdType( Detail.id ) ;
|
||||
location_name = Detail.location ;
|
||||
|
||||
@ -131,6 +135,16 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b
|
||||
|
||||
dns_name = Detail.dyndns ;
|
||||
}
|
||||
else
|
||||
{
|
||||
only_pgp = true ;
|
||||
location_id = SSLIdType() ;
|
||||
location_name = "" ;
|
||||
memset(ipv4_internal_ip_and_port,0,6) ;
|
||||
memset(ipv4_external_ip_and_port,0,6) ;
|
||||
dns_name = "" ;
|
||||
}
|
||||
}
|
||||
|
||||
void RsCertificate::scan_ip(const std::string& ip_string, unsigned short port,unsigned char *ip_and_port)
|
||||
{
|
||||
@ -195,6 +209,7 @@ bool RsCertificate::initFromString(const std::string& instr,std::string& err_str
|
||||
#ifdef DEBUG_RSCERTIFICATE
|
||||
std::cerr << "Packet parse: read ptag " << (int)ptag << ", size " << s << ", total_s = " << total_s << ", expected total = " << size << std::endl;
|
||||
#endif
|
||||
only_pgp = true ;
|
||||
|
||||
switch(ptag)
|
||||
{
|
||||
@ -206,6 +221,7 @@ bool RsCertificate::initFromString(const std::string& instr,std::string& err_str
|
||||
|
||||
case CERTIFICATE_PTAG_NAME_SECTION: location_name = std::string((char *)buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
only_pgp = false ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_SSLID_SECTION:
|
||||
@ -217,10 +233,12 @@ bool RsCertificate::initFromString(const std::string& instr,std::string& err_str
|
||||
|
||||
location_id = SSLIdType(buf) ;
|
||||
buf = &buf[s] ;
|
||||
only_pgp = false ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_DNS_SECTION: dns_name = std::string((char *)buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
only_pgp = false ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_LOCIPANDPORT_SECTION:
|
||||
@ -230,6 +248,7 @@ bool RsCertificate::initFromString(const std::string& instr,std::string& err_str
|
||||
return false ;
|
||||
}
|
||||
|
||||
only_pgp = false ;
|
||||
memcpy(ipv4_internal_ip_and_port,buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
@ -240,6 +259,7 @@ bool RsCertificate::initFromString(const std::string& instr,std::string& err_str
|
||||
return false ;
|
||||
}
|
||||
|
||||
only_pgp = false ;
|
||||
memcpy(ipv4_external_ip_and_port,buf,s) ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
@ -711,6 +731,9 @@ std::string RsCertificate::toStdString_oldFormat() const
|
||||
|
||||
res += PGPKeyManagement::makeArmouredKey(binary_pgp_key,binary_pgp_key_size,pgp_version) ;
|
||||
|
||||
if(only_pgp)
|
||||
return res ;
|
||||
|
||||
res += SSLID_BEGIN_SECTION ;
|
||||
res += location_id.toStdString() ;
|
||||
res += ";" ;
|
||||
@ -775,6 +798,7 @@ bool RsCertificate::initFromString_oldFormat(const std::string& certstr,std::str
|
||||
Radix64::decode(radix_cert,key_bin,binary_pgp_key_size) ;
|
||||
|
||||
binary_pgp_key = (unsigned char *)key_bin ;
|
||||
only_pgp = true ;
|
||||
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "Parsing cert for sslid, location, ext and local address details. : " << certstr << std::endl;
|
||||
@ -792,6 +816,7 @@ bool RsCertificate::initFromString_oldFormat(const std::string& certstr,std::str
|
||||
std::cerr << "SSL id : " << ssl_id << std::endl;
|
||||
|
||||
location_id = SSLIdType(ssl_id) ;
|
||||
only_pgp = false ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -807,6 +832,7 @@ bool RsCertificate::initFromString_oldFormat(const std::string& certstr,std::str
|
||||
std::cerr << "location : " << location << std::endl;
|
||||
|
||||
location_name = location;
|
||||
only_pgp = false ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -832,6 +858,7 @@ bool RsCertificate::initFromString_oldFormat(const std::string& certstr,std::str
|
||||
sscanf(local_port.c_str(), "%hu", &localPort);
|
||||
}
|
||||
|
||||
only_pgp = false ;
|
||||
scan_ip(local_ip,localPort,ipv4_internal_ip_and_port) ;
|
||||
}
|
||||
}
|
||||
@ -858,6 +885,7 @@ bool RsCertificate::initFromString_oldFormat(const std::string& certstr,std::str
|
||||
}
|
||||
|
||||
scan_ip(ext_ip,extPort,ipv4_external_ip_and_port) ;
|
||||
only_pgp = false ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -873,6 +901,7 @@ bool RsCertificate::initFromString_oldFormat(const std::string& certstr,std::str
|
||||
std::cerr << "DynDNS : " << DynDNS << std::endl;
|
||||
|
||||
dns_name = DynDNS;
|
||||
only_pgp = false ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,5 +69,7 @@ class RsCertificate
|
||||
SSLIdType location_id ;
|
||||
std::string pgp_version ;
|
||||
std::string dns_name ;
|
||||
|
||||
bool only_pgp ; // does the cert contain only pgp info?
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
template<uint32_t ID_SIZE_IN_BYTES> class t_RsGenericIdType
|
||||
{
|
||||
public:
|
||||
t_RsGenericIdType() {}
|
||||
t_RsGenericIdType() { memset(bytes,0,ID_SIZE_IN_BYTES) ;}
|
||||
virtual ~t_RsGenericIdType() {}
|
||||
|
||||
// Explicit constructor from a hexadecimal string
|
||||
|
@ -200,7 +200,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
if (!wi)
|
||||
return;
|
||||
|
||||
QMenu contextMnu( this );
|
||||
QMenu *contextMnu = new QMenu;
|
||||
|
||||
std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ;
|
||||
|
||||
@ -213,23 +213,23 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
{
|
||||
if(detail.accept_connection)
|
||||
{
|
||||
QAction* denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), &contextMnu );
|
||||
QAction* denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), contextMnu );
|
||||
|
||||
connect( denyFriendAct , SIGNAL( triggered() ), this, SLOT( denyFriend() ) );
|
||||
contextMnu.addAction( denyFriendAct);
|
||||
contextMnu->addAction( denyFriendAct);
|
||||
}
|
||||
else // not a friend
|
||||
{
|
||||
QAction* makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), &contextMnu );
|
||||
QAction* makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), contextMnu );
|
||||
|
||||
connect( makefriendAct , SIGNAL( triggered() ), this, SLOT( makeFriend() ) );
|
||||
contextMnu.addAction( makefriendAct);
|
||||
contextMnu->addAction( makefriendAct);
|
||||
#ifdef TODO
|
||||
if(detail.validLvl > RS_TRUST_LVL_MARGINAL) // it's a denied old friend.
|
||||
{
|
||||
QAction* deleteCertAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Delete certificate" ), &contextMnu );
|
||||
QAction* deleteCertAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Delete certificate" ), contextMnu );
|
||||
connect( deleteCertAct, SIGNAL( triggered() ), this, SLOT( deleteCert() ) );
|
||||
contextMnu.addAction( deleteCertAct );
|
||||
contextMnu->addAction( deleteCertAct );
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -237,18 +237,18 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
}
|
||||
if(peer_id == rsPeers->getGPGOwnId())
|
||||
{
|
||||
QAction* exportcertAct = new QAction(QIcon(IMAGE_EXPORT), tr( "Export my Cert" ), &contextMnu );
|
||||
QAction* exportcertAct = new QAction(QIcon(IMAGE_EXPORT), tr( "Export my Cert" ), contextMnu );
|
||||
connect( exportcertAct , SIGNAL( triggered() ), this, SLOT( on_actionExportKey_activated() ) );
|
||||
contextMnu.addAction( exportcertAct);
|
||||
contextMnu->addAction( exportcertAct);
|
||||
}
|
||||
|
||||
QAction* peerdetailsAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Peer details..." ), &contextMnu );
|
||||
QAction* peerdetailsAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Peer details..." ), contextMnu );
|
||||
connect( peerdetailsAct , SIGNAL( triggered() ), this, SLOT( peerdetails() ) );
|
||||
contextMnu.addAction( peerdetailsAct);
|
||||
contextMnu->addAction( peerdetailsAct);
|
||||
|
||||
contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
|
||||
contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
contextMnu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void NetworkDialog::denyFriend()
|
||||
|
Loading…
Reference in New Issue
Block a user