QSocks5SocketEnginePrivate::sendRequestMethod(): Fix out of bounds string access

Fix warnings showing in network tests:

tst_QNetworkReply::headFromHttp(rfc+socks):
  Using QCharRef with an index pointing outside the valid range of a QString. The corresponding behavior is deprecated, and will be changed in a future version of Qt.

introduced by qtbase/c2d2757bccc68e1b981df059786c2e76f2969530 (5.14).

Replace index access by QByteArray::append().

Change-Id: I0b4aed563d076237d5f9cc6aa438c7502eb3568c
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
 
 
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Friedemann Kleint 2019-06-24 13:38:54 +02:00
parent 168b18de2d
commit 3ccbf19761

View File

@ -801,9 +801,9 @@ void QSocks5SocketEnginePrivate::sendRequestMethod()
QByteArray buf;
buf.reserve(270); // big enough for domain name;
buf[0] = S5_VERSION_5;
buf[1] = command;
buf[2] = 0x00;
buf.append(char(S5_VERSION_5));
buf.append(command);
buf.append('\0');
if (peerName.isEmpty() && !qt_socks5_set_host_address_and_port(address, port, &buf)) {
QSOCKS5_DEBUG << "error setting address" << address << " : " << port;
//### set error code ....