ti_adc108s102: validate num_entries

num_entries can be as large as 255. However, based on the
_ti_adc108s102 implementation, num_entries must be less than
ADC108S102_CMD_BUFFER_SIZE or the cmd_buffer[] and
sampling_buffer[] arrays in the data struct could overflow.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2018-05-07 11:31:32 -07:00 committed by Anas Nashif
commit 5dc2ab4f47

View file

@ -134,6 +134,10 @@ static inline int _verify_entries(struct adc_seq_table *seq_table)
u32_t chans_set = 0;
int i;
if (seq_table->num_entries >= ADC108S102_CMD_BUFFER_SIZE) {
return 0;
}
for (i = 0; i < seq_table->num_entries; i++) {
entry = &seq_table->entries[i];