Range check item before storing in value array

This commit is contained in:
Paul C Diem 2021-03-13 14:10:32 -06:00
parent 376919edc4
commit eed2c67744

View File

@ -344,18 +344,18 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
value |= *message_ptr++ << 16; value |= *message_ptr++ << 16;
value |= *message_ptr++ << 24; value |= *message_ptr++ << 24;
#ifdef USE_DEVICE_GROUPS_SEND #ifdef USE_DEVICE_GROUPS_SEND
device_group->values_32bit[item - DGR_ITEM_MAX_16BIT - 1] = (item == DGR_ITEM_POWER ? value & 0xffffff : value); if (item < DGR_ITEM_LAST_32BIT) device_group->values_32bit[item - DGR_ITEM_MAX_16BIT - 1] = (item == DGR_ITEM_POWER ? value & 0xffffff : value);
#endif // USE_DEVICE_GROUPS_SEND #endif // USE_DEVICE_GROUPS_SEND
} }
#ifdef USE_DEVICE_GROUPS_SEND #ifdef USE_DEVICE_GROUPS_SEND
else { else {
device_group->values_16bit[item - DGR_ITEM_MAX_8BIT - 1] = value; if (item < DGR_ITEM_LAST_16BIT) device_group->values_16bit[item - DGR_ITEM_MAX_8BIT - 1] = value;
} }
#endif // USE_DEVICE_GROUPS_SEND #endif // USE_DEVICE_GROUPS_SEND
} }
#ifdef USE_DEVICE_GROUPS_SEND #ifdef USE_DEVICE_GROUPS_SEND
else { else {
device_group->values_8bit[item] = value; if (item < DGR_ITEM_LAST_8BIT) device_group->values_8bit[item] = value;
} }
#endif // USE_DEVICE_GROUPS_SEND #endif // USE_DEVICE_GROUPS_SEND
log_length = snprintf(log_ptr, log_remaining, PSTR("%u"), value); log_length = snprintf(log_ptr, log_remaining, PSTR("%u"), value);