mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Support special value "max" where xz and xzdec accept an integer.
Don't round the memory usage limit in xzdec --help to avoid an integer overflow and to not give wrong impression that the limit is high enough when it may not actually be.
This commit is contained in:
parent
03ca67fd37
commit
071b825b23
2 changed files with 9 additions and 1 deletions
|
@ -45,6 +45,10 @@ str_to_uint64(const char *name, const char *value, uint64_t min, uint64_t max)
|
||||||
while (*value == ' ' || *value == '\t')
|
while (*value == ' ' || *value == '\t')
|
||||||
++value;
|
++value;
|
||||||
|
|
||||||
|
// Accept special value "max". Supporting "min" doesn't seem useful.
|
||||||
|
if (strcmp(value, "max") == 0)
|
||||||
|
return max;
|
||||||
|
|
||||||
if (*value < '0' || *value > '9')
|
if (*value < '0' || *value > '9')
|
||||||
message_fatal(_("%s: Value is not a non-negative "
|
message_fatal(_("%s: Value is not a non-negative "
|
||||||
"decimal integer"), value);
|
"decimal integer"), value);
|
||||||
|
|
|
@ -86,7 +86,7 @@ help(void)
|
||||||
" MiB of memory at maximum.\n"
|
" MiB of memory at maximum.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Report bugs to <" PACKAGE_BUGREPORT "> (in English or Finnish).\n",
|
"Report bugs to <" PACKAGE_BUGREPORT "> (in English or Finnish).\n",
|
||||||
argv0, (memlimit + 512 * 1024) / (1024 * 1024));
|
argv0, memlimit / (1024 * 1024));
|
||||||
my_exit();
|
my_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +128,10 @@ str_to_uint64(const char *value)
|
||||||
{
|
{
|
||||||
uint64_t result = 0;
|
uint64_t result = 0;
|
||||||
|
|
||||||
|
// Accept special value "max".
|
||||||
|
if (strcmp(value, "max") == 0)
|
||||||
|
return UINT64_MAX;
|
||||||
|
|
||||||
if (*value < '0' || *value > '9') {
|
if (*value < '0' || *value > '9') {
|
||||||
fprintf(stderr, "%s: %s: Not a number\n", argv0, value);
|
fprintf(stderr, "%s: %s: Not a number\n", argv0, value);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
Loading…
Reference in a new issue