Browse Source

channel: fix bandwidth index validation

Use the validated bandwidth index when accessing bandwidth tables in the
ChirpChat, MeshCore, and Meshtastic channel GUIs. The previous code used the
raw UI value after clamping it into m_bandwidthIndex, allowing negative or
out-of-range array accesses.

Found by cppcheck.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 4 months ago
parent
commit
8aea40f300
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      plugins/channelrx/demodchirpchat/chirpchatdemodgui.cpp
  2. 2
      plugins/channeltx/modchirpchat/chirpchatmodgui.cpp
  3. 2
      plugins/channeltx/modmeshcore/meshcoremodgui.cpp
  4. 2
      plugins/channeltx/modmeshtastic/meshtasticmodgui.cpp

2
plugins/channelrx/demodchirpchat/chirpchatdemodgui.cpp

@ -188,7 +188,7 @@ void ChirpChatDemodGUI::on_BW_valueChanged(int value) @@ -188,7 +188,7 @@ void ChirpChatDemodGUI::on_BW_valueChanged(int value)
m_settings.m_bandwidthIndex = ChirpChatDemodSettings::nbBandwidths - 1;
}
int thisBW = ChirpChatDemodSettings::bandwidths[value];
int thisBW = ChirpChatDemodSettings::bandwidths[m_settings.m_bandwidthIndex];
ui->BWText->setText(QString("%1 Hz").arg(thisBW));
m_channelMarker.setBandwidth(thisBW);
ui->glSpectrum->setSampleRate(thisBW);

2
plugins/channeltx/modchirpchat/chirpchatmodgui.cpp

@ -163,7 +163,7 @@ void ChirpChatModGUI::on_bw_valueChanged(int value) @@ -163,7 +163,7 @@ void ChirpChatModGUI::on_bw_valueChanged(int value)
m_settings.m_bandwidthIndex = ChirpChatModSettings::nbBandwidths - 1;
}
int thisBW = ChirpChatModSettings::bandwidths[value];
int thisBW = ChirpChatModSettings::bandwidths[m_settings.m_bandwidthIndex];
ui->bwText->setText(QString("%1 Hz").arg(thisBW));
m_channelMarker.setBandwidth(thisBW);

2
plugins/channeltx/modmeshcore/meshcoremodgui.cpp

@ -462,7 +462,7 @@ void MeshcoreModGUI::on_bw_valueChanged(int value) @@ -462,7 +462,7 @@ void MeshcoreModGUI::on_bw_valueChanged(int value)
m_settings.m_bandwidthIndex = MeshcoreModSettings::nbBandwidths - 1;
}
int thisBW = MeshcoreModSettings::bandwidths[value];
int thisBW = MeshcoreModSettings::bandwidths[m_settings.m_bandwidthIndex];
ui->bwText->setText(QString("%1 Hz").arg(thisBW));
m_channelMarker.setBandwidth(thisBW);

2
plugins/channeltx/modmeshtastic/meshtasticmodgui.cpp

@ -451,7 +451,7 @@ void MeshtasticModGUI::on_bw_valueChanged(int value) @@ -451,7 +451,7 @@ void MeshtasticModGUI::on_bw_valueChanged(int value)
m_settings.m_bandwidthIndex = MeshtasticModSettings::nbBandwidths - 1;
}
int thisBW = MeshtasticModSettings::bandwidths[value];
int thisBW = MeshtasticModSettings::bandwidths[m_settings.m_bandwidthIndex];
ui->bwText->setText(QString("%1 Hz").arg(thisBW));
m_channelMarker.setBandwidth(thisBW);

Loading…
Cancel
Save