@@ -851,4 +851,78 @@ TEST_F(InspectorSocketTest, HostCheckedForUPGRADE) {
851
851
expect_failure_no_delegate (UPGRADE_REQUEST);
852
852
}
853
853
854
+ TEST_F (InspectorSocketTest, HostIPChecked) {
855
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
856
+ " Host: 10.0.2.555:9229\r\n\r\n " ;
857
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
858
+ INVALID_HOST_IP_REQUEST.length ());
859
+ expect_handshake_failure ();
860
+ }
861
+
862
+ TEST_F (InspectorSocketTest, HostNegativeIPChecked) {
863
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
864
+ " Host: 10.0.-23.255:9229\r\n\r\n " ;
865
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
866
+ INVALID_HOST_IP_REQUEST.length ());
867
+ expect_handshake_failure ();
868
+ }
869
+
870
+ TEST_F (InspectorSocketTest, HostIpOctetOutOfIntRangeChecked) {
871
+ const std::string INVALID_HOST_IP_REQUEST =
872
+ " GET /json HTTP/1.1\r\n "
873
+ " Host: 127.0.0.4294967296:9229\r\n\r\n " ;
874
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
875
+ INVALID_HOST_IP_REQUEST.length ());
876
+ expect_handshake_failure ();
877
+ }
878
+
879
+ TEST_F (InspectorSocketTest, HostIpOctetFarOutOfIntRangeChecked) {
880
+ const std::string INVALID_HOST_IP_REQUEST =
881
+ " GET /json HTTP/1.1\r\n "
882
+ " Host: 127.0.0.18446744073709552000:9229\r\n\r\n " ;
883
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
884
+ INVALID_HOST_IP_REQUEST.length ());
885
+ expect_handshake_failure ();
886
+ }
887
+
888
+ TEST_F (InspectorSocketTest, HostIpEmptyOctetStartChecked) {
889
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
890
+ " Host: .0.0.1:9229\r\n\r\n " ;
891
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
892
+ INVALID_HOST_IP_REQUEST.length ());
893
+ expect_handshake_failure ();
894
+ }
895
+
896
+ TEST_F (InspectorSocketTest, HostIpEmptyOctetMidChecked) {
897
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
898
+ " Host: 127..0.1:9229\r\n\r\n " ;
899
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
900
+ INVALID_HOST_IP_REQUEST.length ());
901
+ expect_handshake_failure ();
902
+ }
903
+
904
+ TEST_F (InspectorSocketTest, HostIpEmptyOctetEndChecked) {
905
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
906
+ " Host: 127.0.0.:9229\r\n\r\n " ;
907
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
908
+ INVALID_HOST_IP_REQUEST.length ());
909
+ expect_handshake_failure ();
910
+ }
911
+
912
+ TEST_F (InspectorSocketTest, HostIpTooFewOctetsChecked) {
913
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
914
+ " Host: 127.0.1:9229\r\n\r\n " ;
915
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
916
+ INVALID_HOST_IP_REQUEST.length ());
917
+ expect_handshake_failure ();
918
+ }
919
+
920
+ TEST_F (InspectorSocketTest, HostIpTooManyOctetsChecked) {
921
+ const std::string INVALID_HOST_IP_REQUEST = " GET /json HTTP/1.1\r\n "
922
+ " Host: 127.0.0.0.1:9229\r\n\r\n " ;
923
+ send_in_chunks (INVALID_HOST_IP_REQUEST.c_str (),
924
+ INVALID_HOST_IP_REQUEST.length ());
925
+ expect_handshake_failure ();
926
+ }
927
+
854
928
} // anonymous namespace
0 commit comments