[Python-checkins] cpython (2.7): Issue #15989: Fix possible integer overflow in str formatting as in unicode

serhiy.storchaka python-checkins at python.org
Sat Jan 19 22:36:49 CET 2013


http://hg.python.org/cpython/rev/ee93a89b4e0f
changeset:   81605:ee93a89b4e0f
branch:      2.7
parent:      81603:5d03f2d81c50
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sat Jan 19 23:35:46 2013 +0200
summary:
  Issue #15989: Fix possible integer overflow in str formatting as in unicode formatting.

files:
  Objects/stringobject.c |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Objects/stringobject.c b/Objects/stringobject.c
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -4355,7 +4355,9 @@
                                     "* wants int");
                     goto error;
                 }
-                width = PyInt_AsLong(v);
+                width = PyInt_AsSsize_t(v);
+                if (width == -1 && PyErr_Occurred())
+                    goto error;
                 if (width < 0) {
                     flags |= F_LJUST;
                     width = -width;
@@ -4392,7 +4394,9 @@
                             "* wants int");
                         goto error;
                     }
-                    prec = PyInt_AsLong(v);
+                    prec = _PyInt_AsInt(v);
+                    if (prec == -1 && PyErr_Occurred())
+                        goto error;
                     if (prec < 0)
                         prec = 0;
                     if (--fmtcnt >= 0)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list