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

postgres panic on non-UTF-8 error message from server #3345

Closed
YgorSouza opened this issue Jul 13, 2024 · 0 comments · Fixed by #3346
Closed

postgres panic on non-UTF-8 error message from server #3345

YgorSouza opened this issue Jul 13, 2024 · 0 comments · Fixed by #3346
Labels

Comments

@YgorSouza
Copy link
Contributor

Bug Description

Tried to connect to a Postgres server with the wrong password. sqlx panicked on this method:

fn get_cached_str(&self, cache: (u16, u16)) -> &str {
// unwrap: this cannot fail at this stage
from_utf8(&self.storage[cache.0 as usize..cache.1 as usize]).unwrap()
}

The server is installed on a Windows Server 2016 machine, and SHOW lc_messages; returns French_France.1252.

I put a dbg! just before the point where it panics, and I got this:

 Notice {
    storage: b"SFATAL\0VFATAL\0C28P01\0Mauthentification par mot de passe \xe9chou\xe9e pour l'utilisateur  \xab postgres \xbb\0Fd:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\libpq\\auth.c\0L336\0Rauth_failed\0\0",
    severity: Fatal,
    message: (
        22,
        96,
    ),
    code: (
        15,
        20,
    ),
}

It panics because of the é character, which is encoded as 0xe9 in windows-1252.

This was partially addressed by #1968, but it seems that not all fields are checked properly.

Minimal Reproduction

Just try to connect to a server as describe above, with an incorrect password.

Info

  • SQLx version: 0.7.4
  • SQLx features enabled: runtime-tokio-native-tls, postgres, chrono
  • Database server and version: Postgres 11.0.4 on Windows Server 2016
  • Operating system: Windows 11
  • rustc --version: 1.79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant