Selaa lähdekoodia

Fix: SetAttributeSingleQoS() read too many bytes from message

This function used GetDintFromMessage() (i. e. 4 bytes) to get DSCP values
from the explicit message body. But the DSCP values are transmitted only
as a single byte. Therefore read only one byte with GetUsintFromMessage().
Also simplified the range check on this unsigned entity.

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Stefan Mätje 6 vuotta sitten
vanhempi
sitoutus
8d7dae0daa
1 muutettua tiedostoa jossa 3 lisäystä ja 4 poistoa
  1. 3 4
      source/src/cip/cipqos.c

+ 3 - 4
source/src/cip/cipqos.c

@@ -85,16 +85,15 @@ EipStatus SetAttributeSingleQoS(
 
   if( NULL != attribute &&
       ( set_bit_mask & ( 1 << ( (attribute_number) % 8 ) ) ) ) {
-    CipUint attribute_value_recieved = GetDintFromMessage(
+    CipUsint attribute_value_received = GetUsintFromMessage(
       &(message_router_request->data) );
 
-    if( !( (attribute_value_recieved <= 0) ||
-           (attribute_value_recieved >= 63) ) ) {
+    if( attribute_value_received < 64u ) {
       OPENER_TRACE_INFO(" setAttribute %d\n", attribute_number);
 
       if(NULL != attribute->data) {
         CipUsint *data = (CipUsint *) attribute->data;
-        *(data) = attribute_value_recieved;
+        *(data) = attribute_value_received;
 
         message_router_response->general_status = kCipErrorSuccess;
       } else {