Add some size checks on the server to ensure received data matches the size from the packet header
This commit is contained in:
parent
215ae6118a
commit
64a0d2c061
1 changed files with 54 additions and 19 deletions
|
|
@ -682,11 +682,18 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Verify the color description size (first 4 bytes of data) |
|
||||
| matches the packet size in the header |
|
||||
\*---------------------------------------------------------*/
|
||||
if(header.pkt_size == *((unsigned int*)data))
|
||||
{
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetColorDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->UpdateLEDs();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS:
|
||||
|
|
@ -695,6 +702,12 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Verify the color description size (first 4 bytes of data) |
|
||||
| matches the packet size in the header |
|
||||
\*---------------------------------------------------------*/
|
||||
if(header.pkt_size == *((unsigned int*)data))
|
||||
{
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
int zone;
|
||||
|
|
@ -704,6 +717,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
controllers[header.pkt_dev_idx]->SetZoneColorDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->UpdateZoneLEDs(zone);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED:
|
||||
|
|
@ -712,6 +726,12 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Verify the single LED color description size (8 bytes) |
|
||||
| matches the packet size in the header |
|
||||
\*---------------------------------------------------------*/
|
||||
if(header.pkt_size == (sizeof(int) + sizeof(RGBColor)))
|
||||
{
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
int led;
|
||||
|
|
@ -721,6 +741,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
controllers[header.pkt_dev_idx]->SetSingleLEDColorDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->UpdateSingleLED(led);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE:
|
||||
|
|
@ -736,11 +757,18 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Verify the mode description size (first 4 bytes of data) |
|
||||
| matches the packet size in the header |
|
||||
\*---------------------------------------------------------*/
|
||||
if(header.pkt_size == *((unsigned int*)data))
|
||||
{
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetModeDescription((unsigned char *)data, client_info->client_protocol_version);
|
||||
controllers[header.pkt_dev_idx]->UpdateMode();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_RGBCONTROLLER_SAVEMODE:
|
||||
|
|
@ -749,11 +777,18 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Verify the mode description size (first 4 bytes of data) |
|
||||
| matches the packet size in the header |
|
||||
\*---------------------------------------------------------*/
|
||||
if(header.pkt_size == *((unsigned int*)data))
|
||||
{
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetModeDescription((unsigned char *)data, client_info->client_protocol_version);
|
||||
controllers[header.pkt_dev_idx]->SaveMode();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_REQUEST_PROFILE_LIST:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue