Browse Source

[5110] Fixed off-by-one error in port checks.

Tomek Mrugalski 8 years ago
parent
commit
9283c872e2

+ 3 - 3
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)));

+ 3 - 3
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)));

+ 1 - 1
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, "<string>:1.40: port must be greater than zero but less than 65535");
+    SYNTAX_ERROR(config, "<string>: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");

+ 1 - 1
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, "<string>:1.111-112: port must be greater than zero but less than 65792");
+    PARSE_FAIL(config, "<string>: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\" , "

+ 2 - 2
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" : "<string>:1.97: port must be greater than zero but less than 65792",
+"syntax-error" : "<string>: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" : "<string>:1.119: port must be greater than zero but less than 65792",
+"syntax-error" : "<string>:1.119: port must be greater than zero but less than 65536",
 "data" :
     {
     "forward-ddns" : {},