New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UINT32 IS BORKED #101
Comments
Thank you. I'll fix it soon. This may be a problem only on 32bit or LLP64 (Windows 64bit). |
Fixed via 7f623c0 |
Also affects 0.3.0 (this is the version in ubuntu 14.04 lts): https://github.com/msgpack/msgpack-python/blob/0.3.0/msgpack/unpack.h#L75 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In 0.4.2 ( and some prior versions ) the C implementation for uint32 decoding is broken:
In unpack_callback_uint32 ( from unpack.h ) the line:
p = PyInt_FromLong((long)d);
causes unsigned 32 bit integers to unpack as negative values in python:
ie. the hex "ce f0 00 00 00" unpacks to -268435456 rather than 4026531840
this can lead to catastrophic data corruption at the application layer when dealing with integers between 2 and 4 billion.
I would recommend changing to:
p = PyLong_FromUnsignedLong((unsigned long)d);
with a possible check against INT32_MAX ( not UINT32_MAX ) to create the slightly smaller/faster PyInt_FromLong() case, but only when the value will not trigger negative interpretation as a PyInt.
The text was updated successfully, but these errors were encountered: