Return an error instead of panicking on unknown response format code#1330
Draft
singhlovepreet9 wants to merge 1 commit into
Draft
Return an error instead of panicking on unknown response format code#1330singhlovepreet9 wants to merge 1 commit into
singhlovepreet9 wants to merge 1 commit into
Conversation
Collaborator
|
It should error on looking up the column. Is this AI generated? |
7d5f499 to
de2642b
Compare
parsePortalRowDescribe (colFmts[i] = format(r.int16())) reads the format code straight off the wire, so a malformed or buggy server response could crash the client with an unrecoverable panic when it reaches decode() instead of surfacing an error the caller can handle. This change catches invalid format codes during parsing of the RowDescription and returns an error immediately, preventing the invalid format from reaching decode() later. Fixes lib#1328
de2642b to
a504ebc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When dealing with a malformed or buggy server response (like in #1328), we can get an unknown format code that isn't text (0) or binary (1).
Previously, this would make it all the way down to
decode()and trigger an unrecoverablepanic("unreachable").This PR changes
parsePortalRowDescribeto check the format code straight off the wire. If it's invalid, we now return a proper error instead of letting it slip through and blow up the client later. This also addresses the previous review feedback to catch the error during column lookup rather than down in the decode loop.Fixes #1328