From f39e542eb859f5f88c65a1b97bdf2f4256c68ec0 Mon Sep 17 00:00:00 2001 From: Alexander Grishkov Date: Tue, 15 Mar 2016 22:54:20 +0300 Subject: Fix parsing of IPv4 addresses with certain symbols Add some extra checks to the parser to make sure that addresses like "300-05" aren't interpreted as valid IPv4 addresses. Change-Id: I12475eebc9452e060779bb05e2b4ad9512a28281 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp index 3e16d3b871..0addd89ebf 100644 --- a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp +++ b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp @@ -186,6 +186,7 @@ void tst_QIpAddress::invalidParseIp4_data() QTest::newRow("..") << ".."; QTest::newRow("...") << "..."; QTest::newRow("....") << "...."; + QTest::newRow(".1.2.3") << ".1.2.3"; QTest::newRow("1.") << "1."; QTest::newRow("1.2.") << "1.2."; QTest::newRow("1.2.3.") << "1.2.3."; @@ -214,9 +215,15 @@ void tst_QIpAddress::invalidParseIp4_data() QTest::newRow("-1.1") << "-1.1"; QTest::newRow("1.-1") << "1.-1"; QTest::newRow("1.1.1.-1") << "1.1.1.-1"; + QTest::newRow("300-05") << "300-05"; + QTest::newRow("127.-1") << "127.-1"; + QTest::newRow("-127-10") << "-127-10"; + QTest::newRow("198.-16") << "198-16"; + QTest::newRow("-127.-0.") << "-127.-0."; // letters QTest::newRow("abc") << "abc"; + QTest::newRow("localhost") << "localhost"; QTest::newRow("1.2.3a.4") << "1.2.3a.4"; QTest::newRow("a.2.3.4") << "a.2.3.4"; QTest::newRow("1.2.3.4a") << "1.2.3.4a"; @@ -249,6 +256,7 @@ void tst_QIpAddress::ip4ToString_data() QTest::newRow("0.0.0.0") << 0u << "0.0.0.0"; QTest::newRow("1.2.3.4") << 0x01020304u << "1.2.3.4"; + QTest::newRow("127.0.0.1") << 0x7f000001u << "127.0.0.1"; QTest::newRow("111.222.33.44") << 0x6fde212cu << "111.222.33.44"; QTest::newRow("255.255.255.255") << 0xffffffffu << "255.255.255.255"; } -- cgit v1.2.3