Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'use-after-dtor' issue in StaticDecoder.cpp #275

Open
pavik opened this issue Mar 15, 2024 · 3 comments
Open

'use-after-dtor' issue in StaticDecoder.cpp #275

pavik opened this issue Mar 15, 2024 · 3 comments

Comments

@pavik
Copy link

pavik commented Mar 15, 2024

Issue appears in EMA library when decoding JSON payload in StaticDecoder::setRsslData
Callstack:

void StaticDecoder::setRsslData( Data* pData, RsslBuffer* pRsslBuffer, RsslDataType rsslType, UInt8 majVer, UInt8 minVer, const RsslDataDictionary* dictionary )
{
     ...
     morph( pData, dType );   // calls destructor on pData
     if ( !pData->getDecoder().setRsslData( majVer, minVer, pRsslBuffer, dictionary, 0 ) )  // <- pure virt function call leads to crash
     ...
}
...
void StaticDecoder::morph( Data* data, DataType::DataTypeEnum dType )
{
	if ( data->getDataType() != dType )
	{
             data->~Data();  // <- object destroyed
             StaticDecoder::create( data, dType );    // <- switch/case does not have default branch so object remains destroyed
	}
}

Hope I explained well, feel free to ask more details if needed.

@ViktorYelizarov
Copy link
Contributor

@pavik Thank you for bringing this issue to our attention! We created an internal Jira to investigate it.

@ViktorYelizarov
Copy link
Contributor

@pavik Could you provide an example how to reproduce this issue?

@pavik
Copy link
Author

pavik commented Mar 15, 2024

Unfortunately I can't provide code snippet it is proprietary. In a nutshell, ETA provider sends refresh message with json payload and EMA consumer initiate request. btw, there is no json data type in EMA DataTypeEnum, it is detected as NoDataEnum. Fortunately payload can be read via msg.getPayload().getData().getAsHex().c_buf(). imho, anyway better to fix, it is dangerous code path that can leave object in destructed state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants