From 60d1738c9153a1163f4ec68f9615ee391994ad89 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 19 May 2024 18:32:44 +0200 Subject: [PATCH] [AX25] Fix possible string truncation --- src/protocols/AX25/AX25.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/protocols/AX25/AX25.cpp b/src/protocols/AX25/AX25.cpp index 7e7d475e..480ea343 100644 --- a/src/protocols/AX25/AX25.cpp +++ b/src/protocols/AX25/AX25.cpp @@ -59,8 +59,8 @@ AX25Frame::AX25Frame(const AX25Frame& frame) infoLen(frame.infoLen), rcvSeqNumber(frame.rcvSeqNumber), sendSeqNumber(frame.sendSeqNumber) { - strncpy(this->destCallsign, frame.destCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN); - strncpy(this->srcCallsign, frame.srcCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN); + strncpy(this->destCallsign, frame.destCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1); + strncpy(this->srcCallsign, frame.srcCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1); if(frame.infoLen) { #if !RADIOLIB_STATIC_ONLY @@ -204,7 +204,7 @@ AX25Client::AX25Client(const AX25Client& ax25) : phyLayer(ax25.phyLayer), sourceSSID(ax25.sourceSSID), preambleLen(ax25.preambleLen) { - strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN); + strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1); #if !RADIOLIB_EXCLUDE_AFSK if(ax25.bellModem) { this->audio = ax25.audio; @@ -217,7 +217,7 @@ AX25Client& AX25Client::operator=(const AX25Client& ax25) { this->phyLayer = ax25.phyLayer; this->sourceSSID = ax25.sourceSSID; this->preambleLen = ax25.preambleLen; - strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN); + strncpy(sourceCallsign, ax25.sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1); #if !RADIOLIB_EXCLUDE_AFSK if(ax25.bellModem) { this->audio = ax25.audio;