[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v3 1/3] 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 66b54bfefe42f2996d1b42c3646511bbd4349317.
---
 mllib/getopt-c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c
index bf40f91..13852c2 100644
--- a/mllib/getopt-c.c
+++ b/mllib/getopt-c.c
@@ -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);
-- 
2.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]