From: Guido van Rossum Date: Sat, 25 Jul 1998 04:14:37 +0000 (+0000) Subject: Make sure that at least one digit has been consumed in atoi(). X-Git-Tag: v1.5.2a1~216 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76310fcc475ce58b3c8495a963519237722e2860;p=python Make sure that at least one digit has been consumed in atoi(). --- diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 2d11851e7c..73a35c9b5c 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -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') {