Allow data size of zero for data length checks if protocol version is 4 or lower, this is to fix backwards compatibility with a bug in older versions OpenRGB.NET that has since been fixed.

This commit is contained in:
Adam Honse 2024-07-28 18:05:47 -05:00
parent 068761872e
commit fdd04a1511

View file

@ -688,8 +688,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Verify the color description size (first 4 bytes of data) | | Verify the color description size (first 4 bytes of data) |
| matches the packet size in the header | | matches the packet size in the header |
| |
| If protocol version is 4 or below, allow the description |
| size to be zero. This allows backwards compatibility with|
| versions of the OpenRGB.NET SDK implementation which had |
| a bug where this field would always be zero. |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
if(header.pkt_size == *((unsigned int*)data)) if((header.pkt_size == *((unsigned int*)data))
|| ((client_info->client_protocol_version <= 4)
&& (*((unsigned int*)data) == 0)))
{ {
if(header.pkt_dev_idx < controllers.size()) if(header.pkt_dev_idx < controllers.size())
{ {
@ -713,8 +720,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Verify the color description size (first 4 bytes of data) | | Verify the color description size (first 4 bytes of data) |
| matches the packet size in the header | | matches the packet size in the header |
| |
| If protocol version is 4 or below, allow the description |
| size to be zero. This allows backwards compatibility with|
| versions of the OpenRGB.NET SDK implementation which had |
| a bug where this field would always be zero. |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
if(header.pkt_size == *((unsigned int*)data)) if((header.pkt_size == *((unsigned int*)data))
|| ((client_info->client_protocol_version <= 4)
&& (*((unsigned int*)data) == 0)))
{ {
if(header.pkt_dev_idx < controllers.size()) if(header.pkt_dev_idx < controllers.size())
{ {
@ -778,8 +792,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Verify the mode description size (first 4 bytes of data) | | Verify the mode description size (first 4 bytes of data) |
| matches the packet size in the header | | matches the packet size in the header |
| |
| If protocol version is 4 or below, allow the description |
| size to be zero. This allows backwards compatibility with|
| versions of the OpenRGB.NET SDK implementation which had |
| a bug where this field would always be zero. |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
if(header.pkt_size == *((unsigned int*)data)) if((header.pkt_size == *((unsigned int*)data))
|| ((client_info->client_protocol_version <= 4)
&& (*((unsigned int*)data) == 0)))
{ {
if(header.pkt_dev_idx < controllers.size()) if(header.pkt_dev_idx < controllers.size())
{ {
@ -803,8 +824,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Verify the mode description size (first 4 bytes of data) | | Verify the mode description size (first 4 bytes of data) |
| matches the packet size in the header | | matches the packet size in the header |
| |
| If protocol version is 4 or below, allow the description |
| size to be zero. This allows backwards compatibility with|
| versions of the OpenRGB.NET SDK implementation which had |
| a bug where this field would always be zero. |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
if(header.pkt_size == *((unsigned int*)data)) if((header.pkt_size == *((unsigned int*)data))
|| ((client_info->client_protocol_version <= 4)
&& (*((unsigned int*)data) == 0)))
{ {
if(header.pkt_dev_idx < controllers.size()) if(header.pkt_dev_idx < controllers.size())
{ {