Commit 88cfcbb7 authored by Peter Eisentraut's avatar Peter Eisentraut

pg_amcheck: Fix block number parsing on command line

The previous code wouldn't handle higher block numbers on systems
where sizeof(long) == 4.
Reviewed-by: default avatarMark Dilger <mark.dilger@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/6a10a211-872b-3c4c-106b-909ae5fefa61%40enterprisedb.com
parent 46490039
......@@ -297,6 +297,7 @@ main(int argc, char *argv[])
long_options, &optindex)) != -1)
{
char *endptr;
unsigned long optval;
switch (c)
{
......@@ -409,30 +410,34 @@ main(int argc, char *argv[])
}
break;
case 7:
opts.startblock = strtol(optarg, &endptr, 10);
if (*endptr != '\0')
errno = 0;
optval = strtoul(optarg, &endptr, 10);
if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid start block");
exit(1);
}
if (opts.startblock > MaxBlockNumber || opts.startblock < 0)
if (optval > MaxBlockNumber)
{
pg_log_error("start block out of bounds");
exit(1);
}
opts.startblock = optval;
break;
case 8:
opts.endblock = strtol(optarg, &endptr, 10);
if (*endptr != '\0')
errno = 0;
optval = strtoul(optarg, &endptr, 10);
if (endptr == optarg || *endptr != '\0' || errno != 0)
{
pg_log_error("invalid end block");
exit(1);
}
if (opts.endblock > MaxBlockNumber || opts.endblock < 0)
if (optval > MaxBlockNumber)
{
pg_log_error("end block out of bounds");
exit(1);
}
opts.endblock = optval;
break;
case 9:
opts.rootdescend = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment