Message60392
On Solaris, socket.ntohs() can return a negative number
when the argument has bit 15 set. This is not according
to spec or intention or expectation. The bug is because
on Solaris, ntohs() is defined as a macro that returns
its argument unchanged, roughly:
#define ntohs(x) (x)
The socket extension casts the argument to (short); it
should use (unsigned short) or something similar.
Here's a program showing the problem (run this on
Solaris, or on another big-endian machine where ntohs()
is defined away):
import socket
print socket.ntohs(-1)
This should print 65535 but prints -1.
(Credit to Andrew Davis for finding this!) |
|
Date |
User |
Action |
Args |
2008-01-20 09:56:25 | admin | link | issue811295 messages |
2008-01-20 09:56:25 | admin | create | |
|