diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -1929,20 +1929,24 @@ } // Configure excessive block size. - const uint64_t nProposedExcessiveBlockSize = + const int64_t nProposedExcessiveBlockSize = args.GetArg("-excessiveblocksize", DEFAULT_MAX_BLOCK_SIZE); - if (!config.SetMaxBlockSize(nProposedExcessiveBlockSize)) { + if (nProposedExcessiveBlockSize <= 0 || + !config.SetMaxBlockSize(nProposedExcessiveBlockSize)) { return InitError( _("Excessive block size must be > 1,000,000 bytes (1MB)")); } // Check blockmaxsize does not exceed maximum accepted block size. - const uint64_t nProposedMaxGeneratedBlockSize = + const int64_t nProposedMaxGeneratedBlockSize = args.GetArg("-blockmaxsize", DEFAULT_MAX_GENERATED_BLOCK_SIZE); - if (nProposedMaxGeneratedBlockSize > config.GetMaxBlockSize()) { - auto msg = _("Max generated block size (blockmaxsize) cannot exceed " - "the excessive block size (excessiveblocksize)"); - return InitError(msg); + if (nProposedMaxGeneratedBlockSize <= 0) { + return InitError(_("Max generated block size must be greater than 0")); + } + if (uint64_t(nProposedMaxGeneratedBlockSize) > config.GetMaxBlockSize()) { + return InitError(_("Max generated block size (blockmaxsize) cannot " + "exceed the excessive block size " + "(excessiveblocksize)")); } // block pruning; get the amount of disk space (in MiB) to allot for block & diff --git a/test/functional/abc-cmdline.py b/test/functional/abc-cmdline.py --- a/test/functional/abc-cmdline.py +++ b/test/functional/abc-cmdline.py @@ -56,9 +56,19 @@ self.nodes[0].assert_start_raises_init_error( ["-excessiveblocksize={}".format(LEGACY_MAX_BLOCK_SIZE)], 'Error: Excessive block size must be > 1,000,000 bytes (1MB)') + self.nodes[0].assert_start_raises_init_error( + ["-excessiveblocksize=0"], + 'Error: Excessive block size must be > 1,000,000 bytes (1MB)') + self.nodes[0].assert_start_raises_init_error( + ["-excessiveblocksize=-1"], + 'Error: Excessive block size must be > 1,000,000 bytes (1MB)') self.log.info(" Attempt to set below blockmaxsize (mining limit)") self.nodes[0].assert_start_raises_init_error( ['-blockmaxsize=1500000', '-excessiveblocksize=1300000'], 'Error: ' + MAX_GENERATED_BLOCK_SIZE_ERROR) + self.nodes[0].assert_start_raises_init_error( + ['-blockmaxsize=0'], 'Error: Max generated block size must be greater than 0') + self.nodes[0].assert_start_raises_init_error( + ['-blockmaxsize=-1'], 'Error: Max generated block size must be greater than 0') # Make sure we leave the test with a node running as this is what thee # framework expects.