mllib: getopt: Further fix int parsing.

Don't allow suffixes on integers, and fix the bounds to match the
definitions of Min_long and Max_long in <caml/mlvalues.h>.

Fixes commit 66b54bfefe.
This commit is contained in:
Richard W.M. Jones
2016-07-18 11:44:23 +01:00
parent bef2d2f30e
commit 4ac1744db4

View File

@@ -124,13 +124,13 @@ strtoint (const char *arg)
{
long int num;
if (xstrtol (arg, NULL, 0, &num, NULL) != LONGINT_OK) {
if (xstrtol (arg, NULL, 0, &num, "") != LONGINT_OK) {
fprintf (stderr, _("%s: '%s' is not a numeric value.\n"),
guestfs_int_program_name, arg);
show_error (EXIT_FAILURE);
}
if (num <= -(2LL<<30) || num >= ((2LL<<30)-1)) {
if (num < -(1<<30) || num > (1<<30)-1) {
fprintf (stderr, _("%s: %s: integer out of range\n"),
guestfs_int_program_name, arg);
show_error (EXIT_FAILURE);