3689 Commits

Author SHA1 Message Date
Anthony Baxter
3d62ffe0fa Backport 50567
#1494314: Fix a regression with high-numbered sockets in 2.4.3. This
means that select() on sockets > FD_SETSIZE (typically 1024) work again.
The patch makes sockets use poll() internally where available.
2006-10-10 16:20:41 +00:00
Martin v. Löwis
b8f82e6feb Backport r45505, r45573, r45576
- reset errno before calling confstr - use confstr() doc to simplify
  checks afterwards
- Correct implementation and documentation of os.confstr.  Add a simple
  test case.  I've yet to figure out how to provoke a None return I can test.
- Address issues brought up by MvL on python-checkins.
  I tested this with valgrind on amd64.

  The man pages I found for diff architectures are inconsistent on this.
  I'm not entirely sure this change is correct for all architectures
  either.

  Perhaps we should just over-allocate and not worry about it?

The change to return None instead of "" in case of unconfigured
values has not been backported.
2006-10-09 19:29:06 +00:00
Andrew M. Kuchling
cebdc5e373 [Partial backport of r45947 | neal.norwitz]
Fix problems found by Coverity.

_ssl.c: under fail: self is DECREF'd, but it would have been NULL.

_csv.c: I'm not sure if lineterminator could have been anything other than
a string.  However, other string method calls are checked, so check this
one too.
2006-10-09 18:30:13 +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
Hye-Shik Chang
2d09be9e48 Backport from trunk r52223:
Bug #1572832: fix a bug in ISO-2022 codecs which may cause segfault
when encoding non-BMP unicode characters.  (Submitted by Ray Chason)
2006-10-08 13:56:00 +00:00
Andrew M. Kuchling
da604c1992 [Backport r50783 | neal.norwitz. The bytes_left code is complicated,
but looks correct on a casual inspection and hasn't been modified
 in the trunk.  Does anyone want to review further?]

Ensure we don't write beyond errText.  I think I got this right, but
it definitely could use some review to ensure I'm not off by one
and there's no possible overflow/wrap-around of bytes_left.
Reported by Klocwork #1.

Fix a problem if there is a failure allocating self->db.
Found with failmalloc.
2006-10-05 18:49:36 +00:00
Andrew M. Kuchling
978809518d [Partial backport of r51218 | neal.norwitz -- the changes to ast.c, symtable.c,
and _elementtree.c weren't applicable]

Klocwork made another run and found a bunch more problems.
This is the first batch of fixes that should be easy to verify based on context.
This fixes problem numbers: 220 (ast), 323-324 (symtable),
321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
2006-10-05 18:37:08 +00:00
Andrew M. Kuchling
9781e5d97e [Partial backport of r50773 | neal.norwitz -- other parts of this patch
applied to pyarena.c, compile.c, and symtable.c, which were different in 2.4.]

Fix more memory allocation issues found with failmalloc.
2006-10-05 18:22:02 +00:00
Andrew M. Kuchling
af4defb79d [Backport r52147 | andrew.kuchling]
Cause a PyObject_Malloc() failure to trigger a MemoryError, and then
add 'if (PyErr_Occurred())' checks to various places so that NULL is
returned properly.
2006-10-05 17:30:48 +00:00
Andrew M. Kuchling
a1ade3e925 [Backport r51223 | neal.norwitz]
If _stat_float_times is false, we will try to INCREF ival which could be NULL.
Return early in that case.  The caller checks for PyErr_Occurred so this
should be ok.

Klocwork #297
2006-10-05 17:24:08 +00:00
Andrew M. Kuchling
165e797817 [Backport r51224 | neal.norwitz]
Move the assert which checks for a NULL pointer first.
Klocwork #274.
2006-10-05 17:22:15 +00:00
Andrew M. Kuchling
68e1e0372b [Backport r51255 | neal.norwitz]
Really address the issue of where to place the assert for leftblock.
(Followup of Klocwork 274)
2006-10-05 17:06:59 +00:00
Andrew M. Kuchling
589f333dfa [Backport r51225 | neal.norwitz]
Try to handle a malloc failure.  I'm not entirely sure this is correct.
There might be something else we need to do to handle the exception.

Klocwork # 212-213

[I think this needs more work; a malloc() failure will cause a match to fail,
 but nothing raises MemoryError.  I'll work on this on the trunk and backport.
 --amk]
2006-10-04 13:30:17 +00:00
Andrew M. Kuchling
d3499a3071 [Backport r51232 | neal.norwitz]
Verify verdat which is returned from malloc is not NULL.
Ensure we don't pass NULL to free.

Klocwork #306 (at least the first part, checking malloc)
2006-10-04 13:20:05 +00:00
Andrew M. Kuchling
3184f24de6 [Backport r51251 | neal.norwitz]
Handle malloc and fopen failures more gracefully.

Klocwork 180-181
2006-10-04 13:14:48 +00:00
Andrew M. Kuchling
a2a1661554 [Backport r51226 | neal.norwitz]
I'm not sure why this code allocates this string for the error message.
I think it would be better to always use snprintf and have the format
limit the size of the name appropriately (like %.200s).

Klocwork #340
2006-10-04 13:12:26 +00:00
Armin Rigo
baab23ec36 Compilation problem caused by conflicting typedefs for uint32_t
(unsigned long vs. unsigned int).
2006-10-04 10:23:57 +00:00
Andrew M. Kuchling
397935f4a3 [Backport r51252 | neal.norwitz]
It's very unlikely, though possible that source is not a string.  Verify
that PyString_AsString() returns a valid pointer.  (The problem can
arise when zlib.decompress doesn't return a string.)

Klocwork 346
2006-10-03 19:39:54 +00:00
Andrew M. Kuchling
1673922296 [backport r51253 | neal.norwitz]
Handle failures from lookup.

Klocwork 341-342
2006-10-03 19:33:56 +00:00
Andrew M. Kuchling
99868849e7 [Backport r51033 | neal.norwitz]
Prevent memory leak on error.

Reported by Klocwork #36
2006-10-03 19:30:04 +00:00
Andrew M. Kuchling
cc17b6f005 [Backport r50858 | neal.norwitz]
No functional change.  Add comment and assert to describe why there
cannot be overflow which was reported by Klocwork.  Discussed on
python-dev.
2006-10-03 19:27:00 +00:00
Andrew M. Kuchling
c45e5d9d91 [Backport r50782 | neal.norwitz]
nextlink can be NULL if teedataobject_new fails, so use XINCREF.
Ensure that dataobj is never NULL.

Reported by Klocwork #102
2006-10-03 19:22:30 +00:00
Andrew M. Kuchling
2b06e0e7a2 [Backport r51229 | neal.norwitz]
Don't deref v if it's NULL.

Klocwork #214
2006-10-03 19:02:58 +00:00
Andrew M. Kuchling
2bf83ca14a [Backport r50781 | neal.norwitz]
Fix memory leaks spotted by Klocwork #37.
2006-10-03 18:55:06 +00:00
Andrew M. Kuchling
612743192e [Backport r50677 | neal.norwitz]
Fix memory leaks in some conditions.

Reported by Klocwork #152.
2006-10-03 18:29:35 +00:00