1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-08-14 23:43:43 -04:00

Fix UDP port validation boolean operations

cppcheck reported boolean expressions being used in bitwise operations
when validating UDP ports. Replace accidental '&' operators with logical
'&&' operators.

Also replace hard-coded port range limits with UINT16_MAX to make the
valid UDP port range explicit and keep UDP source/sink validation
consistent.

No functional change.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
This commit is contained in:
Robin Getz
2026-07-25 20:11:59 -04:00
parent b5f216f049
commit 0ee3237db5
2 changed files with 6 additions and 4 deletions
@@ -16,6 +16,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <cstdint>
#include <QColor>
#include "util/simpleserializer.h"
@@ -167,7 +168,7 @@ bool UDPSinkSettings::deserialize(const QByteArray& data)
d.readU32(21, &u32tmp, 9998);
if ((u32tmp > 1024) & (u32tmp < 65538)) {
if ((u32tmp > 1024) && (u32tmp <= UINT16_MAX)) {
m_udpPort = u32tmp;
} else {
m_udpPort = 9998;
@@ -175,7 +176,7 @@ bool UDPSinkSettings::deserialize(const QByteArray& data)
d.readU32(22, &u32tmp, 9997);
if ((u32tmp > 1024) & (u32tmp < 65538)) {
if ((u32tmp > 1024) && (u32tmp <= UINT16_MAX)) {
m_audioPort = u32tmp;
} else {
m_audioPort = 9997;
@@ -185,7 +186,7 @@ bool UDPSinkSettings::deserialize(const QByteArray& data)
d.readString(24, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(25, &u32tmp, 0);
if ((u32tmp > 1023) && (u32tmp < 65535)) {
if ((u32tmp > 1023) && (u32tmp <= UINT16_MAX)) {
m_reverseAPIPort = u32tmp;
} else {
m_reverseAPIPort = 8888;
@@ -18,6 +18,7 @@
#include "udpsourcesettings.h"
#include <cstdint>
#include <QColor>
#include "util/simpleserializer.h"
@@ -171,7 +172,7 @@ bool UDPSourceSettings::deserialize(const QByteArray& data)
d.readString(18, &m_udpAddress, "127.0.0.1");
d.readU32(19, &u32tmp, 9998);
if ((u32tmp > 1024) & (u32tmp < 65538)) {
if ((u32tmp > 1024) && (u32tmp <= UINT16_MAX)) {
m_udpPort = u32tmp;
} else {
m_udpPort = 9998;