cpython: a84ae2ccd220 (original) (raw)

Mercurial > cpython

changeset 94653:a84ae2ccd220

Issue #23450: Fixed possible integer overflows. [#23450]

Serhiy Storchaka storchaka@gmail.com
date Mon, 16 Feb 2015 20:52:17 +0200
parents d12c7938c4b0
children c0e79e080307
files Modules/_ctypes/_ctypes.c Modules/_elementtree.c Modules/_sqlite/row.c Modules/_tkinter.c Objects/bytesobject.c Objects/obmalloc.c Python/codecs.c Python/marshal.c
diffstat 8 files changed, 64 insertions(+), 50 deletions(-)[+] [-] Modules/_ctypes/_ctypes.c 2 Modules/_elementtree.c 57 Modules/_sqlite/row.c 2 Modules/_tkinter.c 45 Objects/bytesobject.c 2 Objects/obmalloc.c 2 Python/codecs.c 2 Python/marshal.c 2

line wrap: on

line diff

--- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -301,7 +301,7 @@ char * char *new_prefix; char *result; char buf[32];

--- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -11,6 +11,8 @@ -------------------------------------------------------------------- / +#define PY_SSIZE_T_CLEAN + #include "Python.h" #include "structmember.h" @@ -185,8 +187,8 @@ typedef struct { PyObject attrib; / child elements */

/* this either points to _children or to a malloced buffer / PyObject children; @@ -251,7 +253,7 @@ LOCAL(void) dealloc_extra(ElementObject self) { ElementObjectExtra *myextra;

if (!self->extra) return; @@ -429,9 +431,9 @@ element_init(PyObject self, PyObject a } LOCAL(int) -element_resize(ElementObject self, int extra) +element_resize(ElementObject self, Py_ssize_t extra) {

if (size > self->extra->allocated) { /* use Python 2.4's list growth strategy / @@ -453,6 +455,8 @@ element_resize(ElementObject self, int * be safe. */ size = size ? size : 1;

@@ -613,7 +617,7 @@ element_gc_traverse(ElementObject *self, Py_VISIT(JOIN_OBJ(self->tail)); if (self->extra) {

for (i = 0; i < self->extra->length; ++i) @@ -689,7 +693,7 @@ element_clearmethod(ElementObject* self, static PyObject* element_copy(ElementObject* self, PyObject* args) {

-

@@ -1402,7 +1404,7 @@ element_makeelement(PyObject* self, PyOb static PyObject* element_remove(ElementObject* self, PyObject* args) {

PyObject* element; if (!PyArg_ParseTuple(args, "O!:remove", &Element_Type, &element)) @@ -1481,7 +1483,7 @@ static int element_setitem(PyObject* self_, Py_ssize_t index, PyObject* item) { ElementObject* self = (ElementObject*) self_;

{ PyObject *errmsg, *error, *position, *code; elementtreestate *st = ET_STATE_GLOBAL;

@@ -3477,8 +3480,14 @@ xmlparser_parse_whole(XMLParserObject* s break; }

Py_DECREF(buffer);

--- a/Modules/_sqlite/row.c +++ b/Modules/sqlite/row.c @@ -159,7 +159,7 @@ Py_ssize_t pysqlite_row_length(pysqlite PyObject* pysqlite_row_keys(pysqlite_Row* self, PyObject* args, PyObject* kwargs) { PyObject* list;

list = PyList_New(0); if (!list) {

--- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -21,6 +21,7 @@ Copyright (C) 1994 Steen Lumholt. */ +#define PY_SSIZE_T_CLEAN #include "Python.h" #include <ctype.h> @@ -34,7 +35,7 @@ Copyright (C) 1994 Steen Lumholt. #endif #define CHECK_SIZE(size, elemsize) [](#l4.14)

/* If Tcl is compiled for threads, we must also define TCL_THREAD. We define it always; if Tcl is not threaded, the thread functions in @@ -409,7 +410,7 @@ static PyObject * SplitObj(PyObject *arg) { if (PyTuple_Check(arg)) {

size = PyTuple_Size(arg); @@ -425,7 +426,7 @@ SplitObj(PyObject *arg) return NULL; } if (!result) {

@@ -446,7 +447,7 @@ SplitObj(PyObject arg) / Fall through, returning arg. */ } else if (PyList_Check(arg)) {

size = PyList_GET_SIZE(arg); @@ -632,12 +633,12 @@ Tkapp_New(const char screenName, const / some initial arguments need to be in argv */ if (sync || use) { char *args;

if (sync) len += sizeof "-sync"; if (use)

args = (char*)PyMem_Malloc(len); if (!args) { @@ -887,9 +888,14 @@ AsObj(PyObject *value) long longVal; int overflow;

@@ -971,7 +977,7 @@ AsObj(PyObject *value) #endif outbuf[i] = ch; }

@@ -1495,7 +1501,6 @@ var_invoke(EventFunc func, PyObject *sel #ifdef WITH_THREAD TkappObject self = (TkappObject)selfptr; if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {

@@ -2721,20 +2726,20 @@ static PyType_Spec Tkapp_Type_spec = { typedef struct { PyObject* tuple;

} FlattenContext; static int -_bump(FlattenContext* context, int size) +_bump(FlattenContext* context, Py_ssize_t size) { /* expand tuple to hold (at least) size new items. return true if successful, false if an exception was raised */

if (maxsize < context->size + size)

context->maxsize = maxsize; @@ -2746,7 +2751,7 @@ static int { /* add tuple or list to argument tuple (recursively) */

if (depth > 1000) { PyErr_SetString(PyExc_ValueError,

--- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -673,7 +673,7 @@ PyObject " wants int"); goto error; }

--- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1339,7 +1339,7 @@ static void pool = (poolp)usable_arenas->pool_address; assert((block)pool <= (block*)usable_arenas->address + ARENA_SIZE - POOL_SIZE);

--- a/Python/codecs.c +++ b/Python/codecs.c @@ -1006,7 +1006,7 @@ PyObject *PyCodec_NameReplaceErrors(PyOb c = PyUnicode_READ_CHAR(object, i); if (ucnhash_CAPI && ucnhash_CAPI->getname(NULL, c, buffer, sizeof(buffer), 1)) {

--- a/Python/marshal.c +++ b/Python/marshal.c @@ -279,7 +279,7 @@ w_ref(PyObject *v, char *flag, WFILE *p) PyErr_SetString(PyExc_ValueError, "too many objects"); goto err; }