mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user