diff options
author | Eric Blake <eblake@redhat.com> | 2012-03-30 12:03:20 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2012-03-31 09:16:00 -0600 |
commit | 8228a55140f0dac5ddb1e4d78dc899d428e1e07b (patch) | |
tree | 0d156a3ee3d7897b9b3cc622df2f231236a8588d /TODO | |
parent | e967d582f973a4f37db1526f5e455ea643294740 (diff) | |
download | libvirt-python-v6-8228a55140f0dac5ddb1e4d78dc899d428e1e07b.tar.gz libvirt-python-v6-8228a55140f0dac5ddb1e4d78dc899d428e1e07b.tar.xz libvirt-python-v6-8228a55140f0dac5ddb1e4d78dc899d428e1e07b.zip |
Laszlo Ersek pointed out that in trying to convert a long to an
unsigned int, we used:
long long_val = ...;
if ((unsigned int)long_val == long_val)
According to C99 integer promotion rules, the if statement is
equivalent to:
(unsigned long)(unsigned int)long_val == (unsigned long)long_val
since you get an unsigned comparison if at least one side is
unsigned, using the largest rank of the two sides; but on 32-bit
platforms, where unsigned long and unsigned int are the same size,
this comparison is always true and ends up converting negative
long_val into posigive unsigned int values, rather than rejecting
the negative value as we had originally intended (python longs
are unbounded size, and we don't want to do silent modulo
arithmetic when converting to C code).
Fix this by using direct comparisons, rather than casting.
* python/typewrappers.c (libvirt_intUnwrap, libvirt_uintUnwrap)
(libvirt_ulongUnwrap, libvirt_ulonglongUnwrap): Fix conversion
checks.
Diffstat (limited to 'TODO')
0 files changed, 0 insertions, 0 deletions