mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added compile option to use sanitizer and already fixed a few misalignment errors with it
This commit is contained in:
parent
941df6120a
commit
6a18e242bb
@ -827,9 +827,10 @@ int decodeCompactPeerId(struct sockaddr_in *addr, char *enc, int len)
|
||||
|
||||
memset(addr, 0, sizeof(struct sockaddr_in));
|
||||
|
||||
uint32_t *ip = (uint32_t *) (enc);
|
||||
//uint32_t *ip = (uint32_t *) (enc);
|
||||
uint16_t *port = (uint16_t *) (&enc[4]);
|
||||
addr->sin_addr.s_addr = (*ip);
|
||||
|
||||
memcpy(& addr->sin_addr.s_addr, enc, sizeof(in_addr_t)); // aligned version of "addr->sin_addr.s_addr = (*ip); "
|
||||
addr->sin_port = (*port);
|
||||
addr->sin_family = AF_INET;
|
||||
|
||||
|
@ -1945,7 +1945,10 @@ p3FileDatabase::DirSyncRequestId p3FileDatabase::makeDirSyncReqId(const RsPeerId
|
||||
// This is kind of arbitrary. The important thing is that the same ID needs to be generated every time for a given (peer_id,entry index) pair, in a way
|
||||
// that cannot be brute-forced or reverse-engineered, which explains the random bias and the usage of the hash, that is itself random.
|
||||
|
||||
uint64_t r = random_bias ^ *((uint64_t*)tmp.toByteArray()) ;
|
||||
uint64_t tmp2 ;
|
||||
memcpy(&tmp2,tmp.toByteArray(),sizeof(uint64_t));
|
||||
|
||||
uint64_t r = random_bias ^ tmp2;
|
||||
|
||||
#ifdef DEBUG_P3FILELISTS
|
||||
std::cerr << "Creating ID " << std::hex << r << std::dec << " from peer id " << peer_id << " and hash " << hash << std::endl;
|
||||
|
@ -101,14 +101,20 @@ peerAddrInfo::peerAddrInfo()
|
||||
}
|
||||
|
||||
peerConnectState::peerConnectState()
|
||||
: connecttype(0),
|
||||
: dhtVisible(false),
|
||||
connecttype(0),
|
||||
actAsServer(false),
|
||||
lastavailable(0),
|
||||
lastattempt(0),
|
||||
name(""),
|
||||
state(0), actions(0),
|
||||
state(0),
|
||||
actions(0),
|
||||
linkType(0),
|
||||
source(0),
|
||||
inConnAttempt(0),
|
||||
wasDeniedConnection(false), deniedTS(false), deniedInConnAttempt(false)
|
||||
inConnAttempt(false),
|
||||
wasDeniedConnection(false),
|
||||
deniedTS(0),
|
||||
deniedInConnAttempt(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ extern RsGxsChannels* rsGxsChannels;
|
||||
|
||||
struct RsGxsChannelGroup : RsSerializable
|
||||
{
|
||||
RsGxsChannelGroup() : mAutoDownload(false) {}
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mDescription;
|
||||
RsGxsImage mImage;
|
||||
|
@ -61,7 +61,7 @@ namespace RsMemoryManagement
|
||||
|
||||
inline bool chunkOwnsPointer(const Chunk& c,void *p) const
|
||||
{
|
||||
return p >= c._data && (static_cast<unsigned char *>(p)-c._data)/_blockSize < _numBlocks ;
|
||||
return intptr_t(p) >= intptr_t(c._data) && (intptr_t(static_cast<unsigned char *>(p))-intptr_t(c._data))/intptr_t(_blockSize)< intptr_t( _numBlocks );
|
||||
}
|
||||
|
||||
void printStatistics() const ;
|
||||
|
@ -92,6 +92,10 @@ linux-* {
|
||||
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
||||
}
|
||||
|
||||
rs_sanitize {
|
||||
LIBS *= -lasan -lubsan
|
||||
}
|
||||
|
||||
unix {
|
||||
target.path = "$${BIN_DIR}"
|
||||
INSTALLS += target
|
||||
|
@ -58,6 +58,9 @@ linux-g++-64 {
|
||||
OBJECTS_DIR = temp/linux-g++-64/obj
|
||||
}
|
||||
|
||||
rs_sanitize {
|
||||
LIBS *= -lasan -lubsan
|
||||
}
|
||||
#################### Cross compilation for windows under Linux ###################
|
||||
|
||||
win32-x-g++ {
|
||||
|
@ -461,6 +461,10 @@ rs_onlyhiddennode {
|
||||
message("QMAKE: You have enabled only hidden node.")
|
||||
}
|
||||
|
||||
rs_sanitize {
|
||||
QMAKE_CXXFLAGS *= -fsanitize=address -fsanitize=bounds -fsanitize=undefined
|
||||
}
|
||||
|
||||
no_rs_deprecatedwarning {
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-declarations
|
||||
|
Loading…
Reference in New Issue
Block a user