test: Reject + sign when parsing regtest deployment params

The + sign does not make sense for times or heights.
This commit is contained in:
MarcoFalke 2025-05-15 21:25:10 +02:00
parent fa123afa0e
commit fafd43c691
No known key found for this signature in database

View File

@ -53,14 +53,14 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
}
const auto value{arg.substr(found + 1)};
int32_t height;
if (!ParseInt32(value, &height) || height < 0 || height >= std::numeric_limits<int>::max()) {
const auto height{ToIntegral<int32_t>(value)};
if (!height || *height < 0 || *height >= std::numeric_limits<int>::max()) {
throw std::runtime_error(strprintf("Invalid height value (%s) for -testactivationheight=name@height.", arg));
}
const auto deployment_name{arg.substr(0, found)};
if (const auto buried_deployment = GetBuriedDeployment(deployment_name)) {
options.activation_heights[*buried_deployment] = height;
options.activation_heights[*buried_deployment] = *height;
} else {
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
}
@ -72,16 +72,22 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
throw std::runtime_error("Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]");
}
CChainParams::VersionBitsParameters vbparams{};
if (!ParseInt64(vDeploymentParams[1], &vbparams.start_time)) {
const auto start_time{ToIntegral<int64_t>(vDeploymentParams[1])};
if (!start_time) {
throw std::runtime_error(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
}
if (!ParseInt64(vDeploymentParams[2], &vbparams.timeout)) {
vbparams.start_time = *start_time;
const auto timeout{ToIntegral<int64_t>(vDeploymentParams[2])};
if (!timeout) {
throw std::runtime_error(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
}
vbparams.timeout = *timeout;
if (vDeploymentParams.size() >= 4) {
if (!ParseInt32(vDeploymentParams[3], &vbparams.min_activation_height)) {
const auto min_activation_height{ToIntegral<int64_t>(vDeploymentParams[3])};
if (!min_activation_height) {
throw std::runtime_error(strprintf("Invalid min_activation_height (%s)", vDeploymentParams[3]));
}
vbparams.min_activation_height = *min_activation_height;
} else {
vbparams.min_activation_height = 0;
}