Merge pull request #11333 from pcdiem/dgr5

Range check item before storing in value array
This commit is contained in:
Theo Arends 2021-03-14 08:30:47 +01:00 committed by GitHub
commit bf3754d927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

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);