Browse Source

FT8: Fix potential integer overflow in band preset frequency calculation

Fix Coverity CID 649215 (OVERFLOW_BEFORE_WIDEN) by ensuring the band
preset frequency calculation is widened to 64-bit before converting
kHz to Hz.

This prevents a potential 32-bit intermediate overflow when applying
band presets (which is likely not a real issue, but it keeps the
analyzer happy).

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 4 months ago
parent
commit
98f43dfd8c
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 2
      plugins/channelrx/demodft8/ft8demodgui.cpp

2
plugins/channelrx/demodft8/ft8demodgui.cpp

@ -453,7 +453,7 @@ void FT8DemodGUI::on_applyBandPreset_clicked() @@ -453,7 +453,7 @@ void FT8DemodGUI::on_applyBandPreset_clicked()
int bandPresetIndex = ui->bandPreset->currentIndex();
int channelShift = m_settings.getBandPresets(m_settings.m_decoderMode)[bandPresetIndex].m_channelOffset; // kHz
int baseFrequency = m_settings.getBandPresets(m_settings.m_decoderMode)[bandPresetIndex].m_baseFrequency; // kHz
quint64 deviceFrequency = (baseFrequency - channelShift)*1000; // Hz
quint64 deviceFrequency = static_cast<quint64>(baseFrequency - channelShift) * 1000; // Hz
m_ft8Demod->setDeviceCenterFrequency(deviceFrequency, m_settings.m_streamIndex);
if (channelShift * 1000 != m_settings.m_inputFrequencyOffset)

Loading…
Cancel
Save