getopt blindly accepting negative input fix
authorFeideus <erwan.ulrich@gmail.com>
Sun, 24 Jun 2018 09:35:21 +0000 (11:35 +0200)
committerFeideus <erwan.ulrich@gmail.com>
Sun, 24 Jun 2018 10:17:43 +0000 (12:17 +0200)
src/util/getopt_helpers.c

index c55b22fb622f2a1c53adbad8fbec1b37e68c5701..32cce65dd2e44cb57d0b05b8c861b5d97c6a93ac 100644 (file)
@@ -748,6 +748,13 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
   unsigned int *val = scls;
 
   (void) ctx;
+  if('-' == *value)
+  {
+       FPRINTF (stderr,
+               _("Your input for the '%s' option has to be a non negative number \n"),
+               option);
+       return GNUNET_SYSERR;
+  }
   if (1 != SSCANF (value,
                    "%u",
                    val))