Skip to content

Conversation

@elprans
Copy link
Member

@elprans elprans commented May 31, 2018

Currently asyncpg (incorrectly) assumes OIDs to be signed 32-bit
integers, whereas in reality they are unsigned. As a result, things
would crash once the OID sequence reaches 2**31.

Fix this by decoding OID values as unsigned longs.

Fixes: #279

@elprans elprans requested a review from 1st1 May 31, 2018 15:06

oid = typeinfo['oid']
if typeinfo['kind'] != b'b' or typeinfo['elemtype']:
if typeinfo['kind'] not in (b'b', b'd') or typeinfo['elemtype']:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment what b'b' and b'd' mean

except OverflowError:
overflow = True

if overflow or (oid < 0 or oid > 4294967295L):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4294967295L -> 0xFFFFFFFF?


for oid_type in oid_types:
register_core_codec(oid_type,
<encode_func>&int4_encode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add uint4_encode with validation?

elprans added 2 commits May 31, 2018 15:09
Previously this was disallowed for no particular reason.
The current `TestCase.start_cluster()` helper is not flexible enough as it does not allow making customizations to the cluster before it is started. The new `TestCase.new_cluster()` and `TestCase.start_cluster()` are now used instead. Cluster cleanup is now automatic.
Currently asyncpg (incorrectly) assumes OIDs to be signed 32-bit integers, whereas in reality they are unsigned. As a result, things would crash once the OID sequence reaches 2**31. Fix this by decoding OID values as unsigned longs. Fixes: #279
@elprans elprans merged commit 8dd7a6c into master May 31, 2018
@elprans elprans deleted the largeoids branch May 31, 2018 20:53
elprans added a commit that referenced this pull request Jun 13, 2018
This was partially fixed in #300 (as a fix for #279), however that fix missed the fact that OID arrays were still handled using the signed integer codec. Fixes: #316
elprans added a commit that referenced this pull request Jun 13, 2018
This was partially fixed in #300 (as a fix for #279), however that fix missed the fact that OID arrays were still handled using the signed integer codec. Fixes: #316
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants