Discussion:
[Python-3000-checkins] r66021 - in python/branches/py3k: Misc/NEWS Modules/_pickle.c
neal.norwitz
2008-08-24 23:50:09 UTC
Permalink
Author: neal.norwitz
Date: Mon Aug 25 01:50:08 2008
New Revision: 66021

Log:
Issue #3657: Fix uninitialized memory read when pickling longs.

The conversion to the unicode API was incorrect, it should use bytes.
repr is a bad variable name. The use is overloaded, but I'll leave
that to fix later.

R=Brett
TESTED=./python -E -tt ./Lib/test/regrtest.py -uall
valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
./python -E -tt ./Lib/test/regrtest.py test_pickletools


Modified:
python/branches/py3k/Misc/NEWS
python/branches/py3k/Modules/_pickle.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Mon Aug 25 01:50:08 2008
@@ -12,6 +12,9 @@
Core and Builtins
-----------------

+- Issue #3657: Fix uninitialized memory read when pickling longs.
+ Found by valgrind.
+
- Apply security patches from Apple.

- Fix crashes on memory allocation failure found with failmalloc.

Modified: python/branches/py3k/Modules/_pickle.c
==============================================================================
--- python/branches/py3k/Modules/_pickle.c (original)
+++ python/branches/py3k/Modules/_pickle.c Mon Aug 25 01:50:08 2008
@@ -924,10 +924,10 @@
"long too large to pickle");
goto error;
}
- repr = PyUnicode_FromStringAndSize(NULL, (int)nbytes);
+ repr = PyBytes_FromStringAndSize(NULL, (Py_ssize_t)nbytes);
if (repr == NULL)
goto error;
- pdata = (unsigned char *)_PyUnicode_AsString(repr);
+ pdata = (unsigned char *)PyBytes_AS_STRING(repr);
i = _PyLong_AsByteArray((PyLongObject *)obj,
pdata, nbytes,
1 /* little endian */ , 1 /* signed */ );

Loading...