Skip to content
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

hang when preparing statement with too many parameters on firebird 2.5 #312

Open
imccoy opened this issue Sep 12, 2023 · 0 comments
Open

Comments

@imccoy
Copy link

imccoy commented Sep 12, 2023

When you prepare a statement the response comes back including an xdr array. If the length of the array is 32767 (0x00007FFF) or below, everything is fine, but firebird 2.5 has a bug where it encodes the lengths above that incorrectly, for instance 32768 (0x00008000) is encoded as 0xFFFF8000. This causes the allocateAndPrepare callback not to be called and the connection to be left in a broken state.

The ado.net adapter mitigates this by casting to short. The bug seems to be fixed in firebird 3 - I had to drop back to 2.5 to get this test demonstrating the issue to fail.

It's possible to fix here by dropping the first two bytes of the length, then reading the following two bytes as an unsigned short. Is this fix something you're interested in incorporating?

Unfortunately the fix makes array lengths greater than 65535 (0xFFFF) unrepresentable, and I don't know if newer versions of firebird - or other parts of firebird in 2.5 sending xdr arrays - might send arrays longer than that. That means I can't be sure that applying this fix won't create more issues. I'd appreciate your thoughts!

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

No branches or pull requests

1 participant