When converting from dB value to raw value, the control's full range was not checked in case of SND_CTL_TLVT_DB_RANGE.
Check out of range dB values, and return apropriate raw value for the caller.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@nokia.com --- src/control/tlv.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/control/tlv.c b/src/control/tlv.c index 0ff052e..d09766a 100644 --- a/src/control/tlv.c +++ b/src/control/tlv.c @@ -285,13 +285,20 @@ int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax, { switch (tlv[0]) { case SND_CTL_TLVT_DB_RANGE: { + long dbmin, dbmax; unsigned int pos, len; len = int_index(tlv[1]); if (len > MAX_TLV_RANGE_SIZE) return -EINVAL; + if (snd_tlv_get_dB_range(tlv, rangemin, rangemax, + &dbmin, &dbmax)) + return -EINVAL; + if (db_gain <= dbmin || db_gain >= dbmax) { + *value = db_gain <= dbmin ? rangemin : rangemax; + return 0; + } pos = 2; while (pos + 4 <= len) { - long dbmin, dbmax; rangemin = (int)tlv[pos]; rangemax = (int)tlv[pos + 1]; if (!snd_tlv_get_dB_range(tlv + pos + 2,