]> granicus.if.org Git - python/commitdiff
Make sure that at least one digit has been consumed in atoi().
authorGuido van Rossum <guido@python.org>
Sat, 25 Jul 1998 04:14:37 +0000 (04:14 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 25 Jul 1998 04:14:37 +0000 (04:14 +0000)
Modules/stropmodule.c

index 2d11851e7c07e5c8bc58d69c6168f74e0162fafe..73a35c9b5c83fc0cfbed55c598679f99ea48e139 100644 (file)
@@ -705,6 +705,10 @@ strop_atoi(self, args)
                x = (long) PyOS_strtoul(s, &end, base);
        else
                x = PyOS_strtol(s, &end, base);
+       if (end == s || !isxdigit(end[-1])) {
+               PyErr_SetString(PyExc_ValueError, "no digits in int constant");
+               return NULL;
+       }
        while (*end && isspace(Py_CHARMASK(*end)))
                end++;
        if (*end != '\0') {