From: Tomek Mrugalski Date: Fri, 17 Feb 2017 12:49:16 +0000 (+0100) Subject: [5110] Fixed off-by-one error in port checks. X-Git-Tag: trac1205_base^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9283c872e297e76bb7d62aec71920efbfdc43da8;p=thirdparty%2Fkea.git [5110] Fixed off-by-one error in port checks. --- diff --git a/src/bin/d2/d2_parser.cc b/src/bin/d2/d2_parser.cc index b17cec2329..9ba3a3408f 100644 --- a/src/bin/d2/d2_parser.cc +++ b/src/bin/d2/d2_parser.cc @@ -894,8 +894,8 @@ namespace isc { namespace d2 { case 67: #line 274 "d2_parser.yy" // lalr1.cc:859 { - if (yystack_[0].value.as< int64_t > () <= 0 || yystack_[0].value.as< int64_t > () >= 65535 ) { - error(yystack_[0].location, "port must be greater than zero but less than 65535"); + if (yystack_[0].value.as< int64_t > () <= 0 || yystack_[0].value.as< int64_t > () >= 65536 ) { + error(yystack_[0].location, "port must be greater than zero but less than 65536"); } ElementPtr i(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location))); ctx.stack_.back()->set("port", i); @@ -1231,7 +1231,7 @@ namespace isc { namespace d2 { case 127: #line 486 "d2_parser.yy" // lalr1.cc:859 { - if (yystack_[0].value.as< int64_t > () <= 0 || yystack_[0].value.as< int64_t > () >= 65535 ) { + if (yystack_[0].value.as< int64_t > () <= 0 || yystack_[0].value.as< int64_t > () >= 65536 ) { error(yystack_[0].location, "port must be greater than zero but less than 65536"); } ElementPtr i(new IntElement(yystack_[0].value.as< int64_t > (), ctx.loc2pos(yystack_[0].location))); diff --git a/src/bin/d2/d2_parser.yy b/src/bin/d2/d2_parser.yy index 36df4a48ed..5c585d1e8a 100644 --- a/src/bin/d2/d2_parser.yy +++ b/src/bin/d2/d2_parser.yy @@ -272,8 +272,8 @@ ip_address: IP_ADDRESS { }; port: PORT COLON INTEGER { - if ($3 <= 0 || $3 >= 65535 ) { - error(@3, "port must be greater than zero but less than 65535"); + if ($3 <= 0 || $3 >= 65536 ) { + error(@3, "port must be greater than zero but less than 65536"); } ElementPtr i(new IntElement($3, ctx.loc2pos(@3))); ctx.stack_.back()->set("port", i); @@ -484,7 +484,7 @@ dns_server_ip_address: IP_ADDRESS { }; dns_server_port: PORT COLON INTEGER { - if ($3 <= 0 || $3 >= 65535 ) { + if ($3 <= 0 || $3 >= 65536 ) { error(@3, "port must be greater than zero but less than 65536"); } ElementPtr i(new IntElement($3, ctx.loc2pos(@3))); diff --git a/src/bin/d2/tests/d2_cfg_mgr_unittests.cc b/src/bin/d2/tests/d2_cfg_mgr_unittests.cc index 36e035e1be..dc82d2618a 100644 --- a/src/bin/d2/tests/d2_cfg_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_cfg_mgr_unittests.cc @@ -421,7 +421,7 @@ TEST_F(D2CfgMgrTest, invalidEntry) { // Cannot use port 0 config = makeParamsConfigString ("127.0.0.1", 0, 333, "UDP", "JSON"); - SYNTAX_ERROR(config, ":1.40: port must be greater than zero but less than 65535"); + SYNTAX_ERROR(config, ":1.40: port must be greater than zero but less than 65536"); // Cannot use dns server timeout of 0 config = makeParamsConfigString ("127.0.0.1", 777, 0, "UDP", "JSON"); diff --git a/src/bin/d2/tests/d2_simple_parser_unittest.cc b/src/bin/d2/tests/d2_simple_parser_unittest.cc index 07d8357b45..6253f124e6 100644 --- a/src/bin/d2/tests/d2_simple_parser_unittest.cc +++ b/src/bin/d2/tests/d2_simple_parser_unittest.cc @@ -961,7 +961,7 @@ TEST_F(DdnsDomainParserTest, invalidDomain) { " \"dns-servers\" : [ " " { \"ip-address\": \"127.0.0.3\" , " " \"port\": -1 } ] } "; - PARSE_FAIL(config, ":1.111-112: port must be greater than zero but less than 65792"); + PARSE_FAIL(config, ":1.111-112: port must be greater than zero but less than 65536"); // Create a domain configuration without an defined key name config = "{ \"name\": \"example.com\" , " diff --git a/src/bin/d2/tests/testdata/d2_cfg_tests.json b/src/bin/d2/tests/testdata/d2_cfg_tests.json index 4144e381c3..ed0052f3c7 100644 --- a/src/bin/d2/tests/testdata/d2_cfg_tests.json +++ b/src/bin/d2/tests/testdata/d2_cfg_tests.json @@ -1088,7 +1088,7 @@ #----- ,{ "description" : "D2.forward-ddns.dhcp-ddns.dns-servers.port cannot be 0 ", -"syntax-error" : ":1.97: port must be greater than zero but less than 65792", +"syntax-error" : ":1.97: port must be greater than zero but less than 65536", "data" : { "forward-ddns" : @@ -1481,7 +1481,7 @@ #----- ,{ "description" : "D2.reverse-ddns.dhcp-ddns.dns-servers.port cannot be 0 ", -"syntax-error" : ":1.119: port must be greater than zero but less than 65792", +"syntax-error" : ":1.119: port must be greater than zero but less than 65536", "data" : { "forward-ddns" : {},