mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 15:28:28 -05:00
fixed deserialiser for rawWrapper causing crashes when wrapper memory is not initialized properly by the client
This commit is contained in:
parent
86897b60de
commit
76e9387467
@ -543,10 +543,16 @@ void RsTypeSerializer::RawMemoryWrapper::serial_process(
|
||||
break;
|
||||
case RsGenericSerializer::DESERIALIZE:
|
||||
{
|
||||
// In case first,second is not properly initialized, we set them to nullptr,0
|
||||
first = nullptr;
|
||||
second = 0;
|
||||
|
||||
uint32_t serialSize = 0;
|
||||
RS_SERIAL_PROCESS(serialSize);
|
||||
|
||||
if(!ctx.mOk) break;
|
||||
ctx.mOk = serialSize <= MAX_SERIALIZED_CHUNK_SIZE;
|
||||
ctx.mOk = (serialSize <= MAX_SERIALIZED_CHUNK_SIZE);
|
||||
|
||||
if(!ctx.mOk)
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__
|
||||
@ -565,25 +571,23 @@ void RsTypeSerializer::RawMemoryWrapper::serial_process(
|
||||
break;
|
||||
}
|
||||
|
||||
ctx.mOk = ctx.mSize >= ctx.mOffset + serialSize;
|
||||
ctx.mOk = (ctx.mSize >= ctx.mOffset + serialSize);
|
||||
|
||||
if(!ctx.mOk)
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << std::errc::no_buffer_space
|
||||
<< std::endl;
|
||||
RsErr() << __PRETTY_FUNCTION__ << std::errc::no_buffer_space << std::endl;
|
||||
print_stacktrace();
|
||||
|
||||
clear();
|
||||
break;
|
||||
}
|
||||
|
||||
if(serialSize != second)
|
||||
{
|
||||
first = reinterpret_cast<uint8_t*>(realloc(first, serialSize));
|
||||
second = serialSize;
|
||||
}
|
||||
first = reinterpret_cast<uint8_t*>(malloc(serialSize));
|
||||
second = serialSize;
|
||||
|
||||
memcpy(first, ctx.mData + ctx.mOffset, serialSize);
|
||||
ctx.mOffset += serialSize;
|
||||
|
||||
memcpy(first, ctx.mData + ctx.mOffset, second);
|
||||
ctx.mOffset += second;
|
||||
break;
|
||||
}
|
||||
case RsGenericSerializer::PRINT: break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user