2130 Commits

Author SHA1 Message Date
Matthias Klose
8af5d5791b - Issues #2588, #2589: Fix potential integer underflow and overflow
conditions in the PyOS_vsnprintf C API function. CVE-2008-3144.
2008-11-12 07:08:51 +00:00
Martin v. Löwis
ae1c290a05 Prepare for 2.4.5c1 2008-03-02 19:33:40 +00:00
Martin v. Löwis
c8ed4ff565 Backport of r60793:
Added checks for integer overflows, contributed by Google. Some are
only available if asserts are left in the code, in cases where they
can't be triggered from Python code.
2008-03-02 19:20:32 +00:00
Martin v. Löwis
0cc3ea620c Revert the following revisions, as they don't fix security
problems:
52448, 52468, 52472, 52475, 52646, 52797, 52802, 52863, 52999, 53001,
53101, 53371, 53373, 53383, 53384, 53736, 53812, 53921, 55578, 55580,
55581, 55772, 55775, 56557, 57093, 57094, 58630, 60114
2008-03-02 17:47:51 +00:00
Thomas Wouters
1e42ab6e43 Backport trunk revision 53527:
SF patch #1630975: Fix crash when replacing sys.stdout in sitecustomize

When running the interpreter in an environment that would cause it to set
stdout/stderr/stdin's encoding, having a sitecustomize that would replace
them with something other than PyFile objects would crash the interpreter.
Fix it by simply ignoring the encoding-setting for non-files.

This could do with a test, but I can think of no maintainable and portable
way to test this bug, short of adding a sitecustomize.py to the buildsystem
and have it always run with it (hmmm....)
2007-01-23 15:09:19 +00:00
Armin Rigo
eff853ccd7 Backport of r52862. 2006-11-29 22:07:38 +00:00
Andrew M. Kuchling
40e0d6f9e5 [Bug #1542016] Report PCALL_POP value. This makes the return value of sys.callstats() match its docstring. 2006-10-27 13:36:16 +00:00
Ronald Oussoren
392cafba4f Port of universal binary support for Mac OSX from python 2.5. This takes away
the need for the out-of-tree universal binary support that was used to build
the 2.4.3 installer.

Missing here relative to that tree are some changes to IDLE, IMHO those patches
aren't appropriate for the 2.4 branch and users are better of using 2.5's IDLE.
2006-10-08 17:41:25 +00:00
Andrew M. Kuchling
bec63ce9a1 [Backport r46044 | neal.norwitz]
Fix #132 from Coverity, retval could have been derefed
if a continue inside a try failed.
2006-10-06 19:09:36 +00:00
Andrew M. Kuchling
154a884e6b [Backport r51221 | neal.norwitz -- the original commit message is wrong;
this code is only used if WITHOUT_COMPLEX is *not* defined, which is the
 common case for Python builds.]

This code is actually not used unless WITHOUT_COMPLEX is defined.
However, there was no error checking that PyFloat_FromDouble returned
a valid pointer.  I believe this change is correct as it seemed
to follow other code in the area.

Klocwork # 292.
2006-10-05 19:08:30 +00:00
Andrew M. Kuchling
720ea07788 [Backport r51220 | neal.norwitz]
It's highly unlikely, though possible for PyEval_Get*() to return NULLs.
So be safe and do an XINCREF.

Klocwork # 221-222.
2006-10-05 19:01:50 +00:00
Andrew M. Kuchling
e67841f113 [Backport r50685 | neal.norwitz]
Reported by Klocwork #151.

v2 can be NULL if exception2 is NULL.  I don't think that condition can happen,
but I'm not sure it can't either.  Now the code will protect against either
being NULL.
2006-10-05 18:57:54 +00:00
Andrew M. Kuchling
8a28c16430 [Backport r50743 | neal.norwitz]
Handle allocation failures gracefully.  Found with failmalloc.
Many (all?) of these could be backported.
2006-10-05 18:08:58 +00:00
Andrew M. Kuchling
fb369242bd [Backport r51247 | neal.norwitz]
cpathname could be NULL if it was longer than MAXPATHLEN.  Don't try
to write the .pyc to NULL.

Check results of PyList_GetItem() and PyModule_GetDict() are not NULL.

Klocwork 282, 283, 285
2006-10-05 17:19:30 +00:00
Andrew M. Kuchling
3b93688db6 [Backport r51245 | neal.norwitz]
Move/copy assert for tstate != NULL before first use.
Verify that PyEval_Get{Globals,Locals} returned valid pointers.

Klocwork 231-232
2006-10-04 13:17:42 +00:00
Armin Rigo
b2d0f34240 A review of overflow-detecting code in the 2.4 branch.
* unified the way intobject, longobject and mystrtoul handle
  values around -sys.maxint-1.

* in general, trying to entierely avoid overflows in any computation
  involving signed ints or longs is extremely involved.  Fixed a few
  simple cases where a compiler might be too clever (but that's all
  guesswork).

* more overflow checks against bad data in marshal.c.
2006-10-04 10:13:32 +00:00
Andrew M. Kuchling
a2040255ca [Partial backport of r50777 | neal.norwitz]
Handle more mem alloc issues found with failmalloc

[The other half of this patch affected Python/symtable.c, and wasn't
 relevant for the 2.4 branch. --amk]
2006-10-03 19:18:33 +00:00
Andrew M. Kuchling
58e5c1149a [Backport r51443 | neal.norwitz]
Handle a few more error conditions.

Klocwork 301 and 302.  Will backport.
2006-10-03 19:11:32 +00:00
Andrew M. Kuchling
fec7674420 [Backport r51231 | neal.norwitz]
PyModule_GetDict() can fail, produce fatal errors if this happens on startup.

Klocwork #298-299.
2006-10-03 19:08:48 +00:00
Andrew M. Kuchling
1c0d8f0fec [Backport r50678 | neal.norwitz]
Fix memory leak under some conditions.

Reported by Klocwork, #98.
2006-10-03 18:32:25 +00:00
Andrew M. Kuchling
21e2af3562 [Backport rev. 41696 by neal.norwitz]
Fix an int/long mismatch identified here:
        http://www.tortall.net/mu/blog/2005/12/01

Pointed out from SF #1365916.

Backport candidate.
2006-09-29 17:52:32 +00:00
Andrew M. Kuchling
e7031223e3 [Backport of rev. 42093 by neal.norwitz]
Check return result from Py_InitModule*().  This API can fail.

Probably should be backported.
2006-09-27 19:17:32 +00:00
Georg Brandl
b302323c65 Backport fixes for #1523610 (crashes in PyArg_ParseTuple):
rev. 51158 and rev. 50843.
2006-08-09 07:15:29 +00:00
Georg Brandl
4eb9634368 Bug #1535165: fixed a segfault in input() and raw_input() when
sys.stdin is closed.
 (backport from rev. 51129)
2006-08-06 08:23:59 +00:00
Andrew MacIntyre
1fe0665fb6 Complete backport of rev 50787 that was started in rev 50788 2006-07-23 14:29:02 +00:00