Skip to content

Fix handling of OIDs >= 2**31 #300

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

Merged
merged 3 commits into from
May 31, 2018
Merged

Fix handling of OIDs >= 2**31 #300

merged 3 commits into from
May 31, 2018

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
@@ -912,7 +912,7 @@ def __aiter__(self):
raise ValueError('unknown type: {}.{}'.format(schema, typename))

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?

@@ -37,7 +37,7 @@ cdef init_pseudo_codecs():
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants