]> sigrok.org Git - libsigrok.git/commit - src/hardware/asix-sigma/api.c
asix-sigma: fix out-of-range access to the samplerates[] array
authorGerhard Sittig <redacted>
Sun, 16 Oct 2016 16:25:19 +0000 (18:25 +0200)
committerUwe Hermann <redacted>
Mon, 17 Oct 2016 00:05:21 +0000 (02:05 +0200)
commit4154a516de818ace3aabfe5e44cf4c81986074e7
treec36070e5e3bc4be8ee919b959dec2e04e595428a
parent387825dcb1d3ee3fa39286d6048e7bfe86a310b6
asix-sigma: fix out-of-range access to the samplerates[] array

Commit 2c9c0df86eaf removed the sentinel from the samplerates[] array,
but did not adjust the test which checked whether a rate is listed in
the set of supported rates. This could result in an out-of-range access
beyond the array's last item.

Fix the "listed?" check after iterating the table of supported rates.
Cope with either presence or absence of a sentinel in the array.

Address some more style nits while we are here. Rename an identifier
for a local variable which unintentionally might suggest that it would
be a preprocessor macro (all-caps). Reduce redundancy in data type
references as well as in the determination of the array size.

Signed-off-by: Gerhard Sittig <redacted>
src/hardware/asix-sigma/api.c
src/hardware/asix-sigma/protocol.c
src/hardware/asix-sigma/protocol.h