Message49785
Logged In: YES
user_id=21627
The second part of the patch (checking that *u is not
negative) is definitely right.
The first part (requiring an even number of bytes for a u#
argument) probably requires discussion on python-dev (or
this patch should be assigned to MAL): I don't think it
should be allowed to pass a non-Unicode object to u# in the
first place.
In particular, if you pass a byte string, there would be an
implicit assumption that the byte encoding is the same
internal representation as a Py_UNICODE. This is bad -
Python normally assumes the encoding of a string is the
system encoding, which normally is ASCII.
Of course, changing the call to a type error for 2.4.3
probably won't work, either, because it might break existing
code.
Anyway, I believe the latter fix alone should fix the crash:
the current getargs implementation will round down to the
next multiple of sizeof(Py_UNICODE), thanks the integer
division. u_setitem will then refuse the call if the length
is not 1. IOW, it is possible to append between 4 and 7
bytes to a Unicode array.
I wonder why the patch fixes the problem: *u should be an
unsigned, and comparing an unsigned with a signed should
convert the signed to unsigned, no? |
|
| Date |
User |
Action |
Args |
| 2007-08-23 15:47:03 | admin | link | issue1454485 messages |
| 2007-08-23 15:47:03 | admin | create | |
|