summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2023-02-17 12:05:17 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-18 20:19:57 +0000
commite673d5602511af1b216e9d2b010a5a5039e5a7b0 (patch)
treeebfba8e058bab63b64348a31e3bdca23c8984236
parent898df8f84b74b1c5284bd24d042f26974c49cd67 (diff)
downloadqtconnectivity-e673d5602511af1b216e9d2b010a5a5039e5a7b0.tar.gz
sdpscanner: fix URL processing
Do not use the fixed-size temporary buffer, instead just parse the data as a QByteArray. Grepping through BlueZ sources, I could find only several usages of SDP_URL_STR{8,16,32}, and all of them suggest that the url is simply a NULL-terminated string (see [0], [1], [2]). However, the older BlueZ sources suggest that the url can be not NULL-terminated as well (see [3]). To be on a safe side, we provide an implementation that handles both cases correctly. [0]: https://github.com/bluez/bluez/blob/9be85f867856195e16c9b94b605f65f6389eda33/lib/sdp.c#L465 [1]: https://github.com/bluez/bluez/blob/9be85f867856195e16c9b94b605f65f6389eda33/src/sdp-xml.c#L351 [2]: https://github.com/bluez/bluez/blob/9be85f867856195e16c9b94b605f65f6389eda33/tools/sdptool.c#L517 [3]: https://android.googlesource.com/platform/external/bluetooth/bluez/+/master/src/sdp-xml.c#324 Fixes: QTBUG-111242 Change-Id: I22f9521582863fb316dd0b2c49a78928b80a6078 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit a811bcb3e76e98d480581634b84daf5c8948aceb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/tools/sdpscanner/main.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/tools/sdpscanner/main.cpp b/src/tools/sdpscanner/main.cpp
index 946596bb..1f62d2a7 100644
--- a/src/tools/sdpscanner/main.cpp
+++ b/src/tools/sdpscanner/main.cpp
@@ -175,9 +175,8 @@ static void parseAttributeValues(sdp_data_t *data, int indentation, QByteArray &
case SDP_URL_STR8:
case SDP_URL_STR16:
case SDP_URL_STR32:
- strncpy(snBuffer, data->val.str, data->unitSize - 1);
xmlOutput.append("<url value=\"");
- xmlOutput.append(snBuffer);
+ xmlOutput.append(data->val.str, qstrnlen(data->val.str, data->unitSize));
xmlOutput.append("\"/>\n");
break;
default: