-
Couldn't load subscription status.
- Fork 133
Description
Problem/Opportunity
if websocket connection to the server of type:
StreamJSONType<Web::WebSocket::WebSocketServerTypeCore::SocketStream, JSONObjectFactory &, Core::JSON::IElement>
sends garbage data like:
dfsda
the https://github.com/rdkcentral/Thunder/blob/R4.4.4/Source/core/StreamJSON.h#L287 hangs into inifinite loop due to issues with:
https://github.com/rdkcentral/Thunder/blob/R4.4.4/Source/core/JSON.h#L446
For the first 4 bytes of ie "dfsda" the slice length is >=2, so the if (loaded + 1 == maxLength) guard is false. It does the compare, it mismatches, and the post-increment loaded → Deserialize() returns loaded == 1, and the loop advances by 1.
For the last call the slice is length 1. Now loaded + 1 == maxLength is true at the very start, so it set UNKNOWN and breaks without consuming that byte. The caller from StreamJSON sees loaded == 0 and spins forever on the same last byte.
Steps to reproduce
No response
Expected Behavior
'loaded' increments for all chars what breaks the while loop
Actual Behavior
'loaded' doesn't increment for the last char, so while loop never ends
Notes (Optional)
No response