mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-12 00:23:08 -04:00
Merge of branch v0.6-rssocialnet 7419 to 7488. Changes from electron and myself:
- added possibility to modify groups (e.g. edit circles) - fixed mismatched free/delete in fimonitor.cc, authssl.cc, pqibin.cc (saving encrypted hash cache file) - improved plugin interface class to allow plugins to access GXS objects. - added method to un-register notify clients from RsNotify - fixed pqisslproxy for windows, due to win not properly supporting sockets in non blocking mode. - removed static members form RsInitConfig and made RsAccounts object a pointer. This prevents plugin initialisation problems at symbol resolving time. - removed bool return from p3IdService::getOwnIds() git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7492 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
906efa6f6c
commit
f6db432c74
24 changed files with 525 additions and 322 deletions
|
@ -1253,7 +1253,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen,
|
|||
}
|
||||
|
||||
// now assign memory to out accounting for data, and cipher block size, key length, and key length val
|
||||
out = new unsigned char[inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH];
|
||||
out = (unsigned char*)malloc(inlen + cipher_block_size + size_net_ekl + eklen + EVP_MAX_IV_LENGTH);
|
||||
|
||||
net_ekl = htonl(eklen);
|
||||
memcpy((unsigned char*)out + out_offset, &net_ekl, size_net_ekl);
|
||||
|
@ -1268,7 +1268,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen,
|
|||
// now encrypt actual data
|
||||
if(!EVP_SealUpdate(&ctx, (unsigned char*) out + out_offset, &out_currOffset, (unsigned char*) in, inlen)) {
|
||||
free(ek);
|
||||
delete[] (unsigned char*) out;
|
||||
free(out);
|
||||
out = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -1279,7 +1279,7 @@ bool AuthSSLimpl::encrypt(void *&out, int &outlen, const void *in, int inlen,
|
|||
// add padding
|
||||
if(!EVP_SealFinal(&ctx, (unsigned char*) out + out_offset, &out_currOffset)) {
|
||||
free(ek);
|
||||
delete[] (unsigned char*) out;
|
||||
free(out) ;
|
||||
out = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -1360,11 +1360,11 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
|||
return false;
|
||||
}
|
||||
|
||||
out = new unsigned char[inlen - in_offset];
|
||||
out = (unsigned char*)malloc(inlen - in_offset);
|
||||
|
||||
if(!EVP_OpenUpdate(&ctx, (unsigned char*) out, &out_currOffset, (unsigned char*)in + in_offset, inlen - in_offset)) {
|
||||
free(ek);
|
||||
delete[] (unsigned char*) out;
|
||||
free(out) ;
|
||||
out = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -1374,7 +1374,7 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
|||
|
||||
if(!EVP_OpenFinal(&ctx, (unsigned char*)out + out_currOffset, &out_currOffset)) {
|
||||
free(ek);
|
||||
delete[] (unsigned char*) out;
|
||||
free(out) ;
|
||||
out = NULL;
|
||||
return false;
|
||||
}
|
||||
|
@ -1386,9 +1386,9 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
|
|||
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
std::cerr << "AuthSSLimpl::decrypt() finished with outlen : " << outlen << std::endl;
|
||||
#endif
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
std::cerr << "AuthSSLimpl::decrypt() finished with outlen : " << outlen << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "pqi/p3notify.h"
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
|
||||
RsNotify *rsNotify = NULL ;
|
||||
|
||||
|
@ -284,3 +285,16 @@ void p3Notify::registerNotifyClient(NotifyClient *cl)
|
|||
notifyClients.push_back(cl) ;
|
||||
}
|
||||
|
||||
bool p3Notify::unregisterNotifyClient(NotifyClient *nc)
|
||||
{
|
||||
std::list<NotifyClient*>::iterator it = std::find(notifyClients.begin(), notifyClients.end(), nc);
|
||||
if(it != notifyClients.end())
|
||||
{
|
||||
notifyClients.erase(it);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ class p3Notify: public RsNotify
|
|||
virtual ~p3Notify() { return; }
|
||||
|
||||
virtual void registerNotifyClient(NotifyClient *nc) ;
|
||||
virtual bool unregisterNotifyClient(NotifyClient *nc) ;
|
||||
|
||||
/* Pull output methods for retroshare-gui */
|
||||
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg);
|
||||
|
|
|
@ -185,7 +185,7 @@ BinEncryptedFileInterface::~BinEncryptedFileInterface()
|
|||
{
|
||||
if((sizeData > 0) && data != NULL)
|
||||
{
|
||||
delete[] data;
|
||||
free(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ BinEncryptedFileInterface::~BinEncryptedFileInterface()
|
|||
int BinEncryptedFileInterface::senddata(void* data, int len)
|
||||
{
|
||||
|
||||
char* encrytedData = NULL;
|
||||
void* encrytedData = NULL;
|
||||
int encDataLen = 0;
|
||||
|
||||
// encrypt using own ssl public key
|
||||
|
@ -205,8 +205,8 @@ int BinEncryptedFileInterface::senddata(void* data, int len)
|
|||
|
||||
if((encDataLen > 0) && (encrytedData != NULL))
|
||||
{
|
||||
BinFileInterface::senddata(encrytedData, encDataLen);
|
||||
delete[] encrytedData;
|
||||
BinFileInterface::senddata((unsigned char *)encrytedData, encDataLen);
|
||||
free(encrytedData);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -288,7 +288,7 @@ int BinEncryptedFileInterface::close()
|
|||
{
|
||||
if(data != NULL)
|
||||
{
|
||||
delete[] data;
|
||||
free(data);
|
||||
sizeData = 0;
|
||||
haveData = false;
|
||||
cpyCount = 0;
|
||||
|
|
|
@ -214,10 +214,45 @@ int pqisslproxy::Proxy_Method_Response()
|
|||
|
||||
char method_response[2];
|
||||
|
||||
// read from the socket.
|
||||
int recvd = recv(sockfd, method_response, 2, MSG_WAITALL);
|
||||
/*
|
||||
first it was:
|
||||
|
||||
int recvd = recv(sockfd, method_response, 2, MSG_WAITALL);
|
||||
|
||||
this does not work on windows, because the socket is in nonblocking mode
|
||||
the winsock reference says about the recv function and MSG_WAITALL:
|
||||
|
||||
"Note that if the underlying transport does not support MSG_WAITALL,
|
||||
or if the socket is in a non-blocking mode, then this call will fail with WSAEOPNOTSUPP."
|
||||
|
||||
now it is a two step process:
|
||||
|
||||
int recvd = recv(sockfd, method_response, 2, MSG_PEEK); // test how many bytes are in the input queue
|
||||
if (enaugh bytes available){
|
||||
recvd = recv(sockfd, method_response, 2, 0);
|
||||
}
|
||||
|
||||
this does not work on windows:
|
||||
if ((recvd == -1) && (errno == EAGAIN)) return TRY_AGAIN_LATER;
|
||||
|
||||
instead have to do:
|
||||
if ((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK)) return TRY_AGAIN_LATER;
|
||||
*/
|
||||
|
||||
// test how many bytes can be read from the queue
|
||||
int recvd = recv(sockfd, method_response, 2, MSG_PEEK);
|
||||
if (recvd != 2)
|
||||
{
|
||||
#ifdef WINDOWS_SYS
|
||||
if ((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK))
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Method_Response() waiting for more data (windows)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((recvd == -1) && (errno == EAGAIN))
|
||||
{
|
||||
|
||||
|
@ -227,15 +262,36 @@ int pqisslproxy::Proxy_Method_Response()
|
|||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else if (recvd == -1)
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Method_Response() Error recving response";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "pqisslproxy::Proxy_Method_Response() recv error peek";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Method_Response() waiting for more data";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// read the bytes
|
||||
recvd = recv(sockfd, method_response, 2, 0);
|
||||
if (recvd != 2)
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Method_Response() recv error";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
// does it make sense?
|
||||
if (method_response[0] != 0x05)
|
||||
{
|
||||
|
@ -345,9 +401,20 @@ int pqisslproxy::Proxy_Connection_Complete()
|
|||
|
||||
char socks_response[MAX_SOCKS_REQUEST_LEN];
|
||||
|
||||
int recvd = recv(sockfd, socks_response, 5, MSG_WAITALL);
|
||||
// test how many bytes can be read
|
||||
int recvd = recv(sockfd, socks_response, 5, MSG_PEEK);
|
||||
if (recvd != 5)
|
||||
{
|
||||
#ifdef WINDOWS_SYS
|
||||
if ((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK))
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data (windows)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((recvd == -1) && (errno == EAGAIN))
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
|
@ -356,13 +423,34 @@ int pqisslproxy::Proxy_Connection_Complete()
|
|||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (recvd == -1)
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error peek";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// read the bytes
|
||||
recvd = recv(sockfd, socks_response, 5, 0);
|
||||
if (recvd != 5)
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
// error checking.
|
||||
if (socks_response[0] != 0x05)
|
||||
|
@ -429,10 +517,20 @@ int pqisslproxy::Proxy_Connection_Complete()
|
|||
}
|
||||
|
||||
|
||||
// read the remaining bytes.
|
||||
recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, MSG_WAITALL); // address_bytes - 1 + 2...
|
||||
// test how many bytes can be read
|
||||
recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, MSG_PEEK); // address_bytes - 1 + 2...
|
||||
if (recvd != address_bytes + 1)
|
||||
{
|
||||
#ifdef WINDOWS_SYS
|
||||
if((recvd == -1) && (WSAGetLastError() == WSAEWOULDBLOCK))
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data(2) (windows)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((recvd == -1) && (errno == EAGAIN))
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
|
@ -442,14 +540,35 @@ int pqisslproxy::Proxy_Connection_Complete()
|
|||
// Waiting - shouldn't happen.
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (recvd == -1)
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() ERROR recving(2)";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() ERROR recving(2)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() waiting for more data(2)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// read the bytes
|
||||
recvd = recv(sockfd, &(socks_response[5]), address_bytes + 1, 0); // address_bytes - 1 + 2...
|
||||
if (recvd != address_bytes + 1)
|
||||
{
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() recv error (2)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef PROXY_DEBUG
|
||||
std::cerr << "pqisslproxy::Proxy_Connection_Complete() Received String: ";
|
||||
for(int i = 0; i < 4 + address_bytes + 2; i++)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue