[EVENTCREATE]: Use wcstoul() to retrieve and check for valid numerical values.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 1 Sep 2017 20:35:25 +0000 (20:35 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Fri, 1 Sep 2017 20:35:25 +0000 (20:35 +0000)
svn path=/trunk/; revision=75733

reactos/base/applications/cmdutils/eventcreate/eventcreate.c

index ddf7da2..ebd879f 100644 (file)
@@ -914,7 +914,18 @@ DoParse(
                 // case TYPE_U16:
                 case TYPE_U32:
                 {
-                    *(ULONG*)Options[Option].Value = (ULONG)_wtol(argv[i]);
+                    PWCHAR pszNext = NULL;
+
+                    /* The number is specified in base 10 */
+                    // NOTE: We might use '0' so that the base is automatically determined.
+                    *(ULONG*)Options[Option].Value = wcstoul(argv[i], &pszNext, 10);
+                    if (*pszNext)
+                    {
+                        /* The value is not a valid numeric value and is not allowed */
+                        if (PrintErrorFunc)
+                            PrintErrorFunc(InvalidValue, argv[i], OptionStr);
+                        return FALSE;
+                    }
                     break;
                 }