From 76310fcc475ce58b3c8495a963519237722e2860 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sat, 25 Jul 1998 04:14:37 +0000 Subject: [PATCH] Make sure that at least one digit has been consumed in atoi(). --- Modules/stropmodule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 2d11851e7c0..73a35c9b5c8 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') {