From 4a79ac857cb675abbd989f5b9ae21dea8016e74e Mon Sep 17 00:00:00 2001 From: Martin Negyokru Date: Tue, 6 Jun 2023 15:53:46 +0200 Subject: Validate QNetworkProxy::applicationProxy configs Invalid proxy settings may result in a crash in chromium. Use chromium's helper function that validates proxy configs instead of constructing net::ProxyServer manually. On invalid input, result will be a `SCHEME_INVALID` ProxyServer. Fixes: QTBUG-113992 Pick-to: 6.5 6.6 Change-Id: I1745ae3c3cd4da40d3d8b92a14f752ac9b3f8d31 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/widgets/proxy/tst_proxy.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/proxy/tst_proxy.cpp b/tests/auto/widgets/proxy/tst_proxy.cpp index f378ae22f..3dc72618c 100644 --- a/tests/auto/widgets/proxy/tst_proxy.cpp +++ b/tests/auto/widgets/proxy/tst_proxy.cpp @@ -8,7 +8,7 @@ #include #include #include - +#include struct Interceptor : public QWebEngineUrlRequestInterceptor { @@ -28,6 +28,7 @@ public: private slots: void proxyAuthentication(); void forwardCookie(); + void invalidHostName(); }; @@ -72,6 +73,19 @@ void tst_Proxy::forwardCookie() QTRY_VERIFY2(cookieSpy.size() > 0, "Could not get cookie"); } +// Crash test ( https://bugreports.qt.io/browse/QTBUG-113992 ) +void tst_Proxy::invalidHostName() +{ + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName("999.0.0.0"); + QNetworkProxy::setApplicationProxy(proxy); + QWebEnginePage page; + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + page.load(QUrl("http://www.qt.io")); + QTRY_COMPARE_WITH_TIMEOUT(loadSpy.size(), 1, 20000); +} + #include "tst_proxy.moc" QTEST_MAIN(tst_Proxy) -- cgit v1.2.3