#2028 - Check for Cr or LF.

This commit is contained in:
srcejon 2024-04-03 15:14:14 +01:00
parent 4d3e9889ec
commit eac144acba
2 changed files with 9 additions and 9 deletions

View File

@ -185,7 +185,7 @@ bool APRSPacket::decode(AX25Packet packet)
qDebug() << "APRSPacket::decode: AX.25 Destination did not match known regexp " << m_to;
}
} else {
qDebug() << "APRSPacket::decode: Not ARPS: type=" << packet.m_type << " pid=" << packet.m_pid << " length=" << packet.m_data.length();
qDebug() << "APRSPacket::decode: Not APRS: type=" << packet.m_type << " pid=" << packet.m_pid << " length=" << packet.m_data.length();
}
return false;

View File

@ -261,17 +261,17 @@ struct SDRBASE_API APRSPacket {
data.append(':');
// #2028 - Protect against APRS-IS server command injection, by only sending up to first CR/LF
int idx = m_data.indexOf("\r\n");
if (idx >= 0)
{
data.append(m_data.left(idx + 2));
int idx = m_data.indexOf("\r");
if (idx == -1) {
idx = m_data.indexOf("\n");
}
else
{
if (idx >= 0) {
data.append(m_data.left(idx));
} else {
data.append(m_data);
data.append('\r');
data.append('\n');
}
data.append('\r');
data.append('\n');
return data;
}