summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-02-17 17:58:35 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-18 20:20:03 +0000
commitf101f8254620c7ef4c771ab00055ba58bec7b8dd (patch)
treed5d497910670a1480cc1ef0b99881528c8e960d9
parentc97efb48b5a2c57987d05973d7c370147c89f6d8 (diff)
sdpscanner: fix potential unwanted truncation for SDP_TEXT_STR{8,16,32}
QByteArray::resize() treats all negative parameters as a request for a zero length. So the code text.resize(text.indexOf('\0')); can completely erase the text if there is no '\0' in it. Fix it by explicitly checking the return value of QByteArray::indexOf(). Change-Id: Idc42bf4b96a9be5b007916263d6cf1e831b96c07 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 58cb7eeea5c05e42efc806716eb5eb39bd25787b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/tools/sdpscanner/main.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/sdpscanner/main.cpp b/src/tools/sdpscanner/main.cpp
index 1f62d2a7..d0c3e2cc 100644
--- a/src/tools/sdpscanner/main.cpp
+++ b/src/tools/sdpscanner/main.cpp
@@ -123,7 +123,9 @@ static void parseAttributeValues(sdp_data_t *data, int indentation, QByteArray &
break;
} else if (!isprint(text[i])) {
hasNonPrintableChar = true;
- text.resize(text.indexOf('\0')); // cut trailing content
+ const auto firstNullIdx = text.indexOf('\0');
+ if (firstNullIdx > 0)
+ text.resize(firstNullIdx); // cut trailing content
break;
}
}