mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-08-10 13:33:49 -04:00
rtl-sdr: Fix out-of-bounds tuner name lookup
Validate the tuner type index before accessing the tuner name table. The previous check allowed an index equal to names.size(), which could result in an out-of-range QStringList access. Use a local integer value for the enum conversion and ensure only valid indices are used when looking up tuner names. pointed out by cppcheck: Access out of bounds Signed-off-by: Robin Getz <rgetz503@gmail.com>
This commit is contained in:
@@ -469,8 +469,10 @@ QString RTLSDRInput::getTunerName() const
|
||||
{
|
||||
const static QStringList names = {"Unknown", "E4000", "FC0012", "FC0013", "FC2580", "R820T", "R828D"};
|
||||
|
||||
if ((int) m_tunerType <= names.size()) {
|
||||
return names[(int) m_tunerType];
|
||||
const int tunerType = (int) m_tunerType;
|
||||
|
||||
if (tunerType >= 0 && tunerType < names.size()) {
|
||||
return names[tunerType];
|
||||
} else {
|
||||
return names[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user