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

PgCat Reads Past Buffer on Error During Server Login #876

Open
tneely opened this issue Nov 21, 2024 · 0 comments
Open

PgCat Reads Past Buffer on Error During Server Login #876

tneely opened this issue Nov 21, 2024 · 0 comments

Comments

@tneely
Copy link

tneely commented Nov 21, 2024

Describe the bug

When reading an error message from the server during login, PgCat creates an array of bytes equal to the message length - vec![0u8; len as usize].

However Postgres includes the size in the length, and we already read it from the stream, so we end up trying to read more than what's in the buffer and eventually get an UnexpectedEof when Postgres closes the connection.

https://github.com/postgresml/pgcat/blob/main/src/server.rs#L710-L712

We need to subtract 4 from the length similar to what is done for ReadyForQuery - https://github.com/postgresml/pgcat/blob/main/src/server.rs#L787

To Reproduce

  1. Configure invalid credentials
  2. Try to start and connect to PgCat
  3. Inspect the error logs and see that the auth error is missing

Expected behavior
PgCat handles error messages from the server correctly during startup.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: aarch64 / AL2
  • Browser: N/A
  • Version: Postgres 16 / PgCat 1.2.0

Additional context
Add any other context about the problem here.

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