Skip to content

Commit beca9a6

Browse files
committed
probes: bound sample-rate index to the table size
The four-bit sample-rate field could select an index past the rate table, which has fewer entries. Bound the index against the table size. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 3f7738d commit beca9a6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tools/probes/probes_demux.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,15 @@ int init_wave(struct dma_frame_parser *p, uint32_t buffer_id, uint32_t format)
125125
p->files[i].header.fmt.subchunk_size = 16;
126126
p->files[i].header.fmt.audio_format = 1;
127127
p->files[i].header.fmt.num_channels = ((format & PROBE_MASK_NB_CHANNELS) >> PROBE_SHIFT_NB_CHANNELS) + 1;
128-
p->files[i].header.fmt.sample_rate = sample_rate[(format & PROBE_MASK_SAMPLE_RATE) >> PROBE_SHIFT_SAMPLE_RATE];
128+
/* the sample-rate field is 4 bits (0-15) but the table has fewer
129+
* entries; bound the index so an out-of-range value does not read
130+
* past the table
131+
*/
132+
uint32_t rate_idx = (format & PROBE_MASK_SAMPLE_RATE) >> PROBE_SHIFT_SAMPLE_RATE;
133+
134+
p->files[i].header.fmt.sample_rate =
135+
rate_idx < sizeof(sample_rate) / sizeof(sample_rate[0]) ?
136+
sample_rate[rate_idx] : 0;
129137
p->files[i].header.fmt.bits_per_sample = (((format & PROBE_MASK_CONTAINER_SIZE) >> PROBE_SHIFT_CONTAINER_SIZE) + 1) * 8;
130138
p->files[i].header.fmt.byte_rate = p->files[i].header.fmt.sample_rate *
131139
p->files[i].header.fmt.num_channels *

0 commit comments

Comments
 (0)