pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Windows locale cause server to send invalid data encoding to client
5+ messages / 3 participants
[nested] [flat]

* Windows locale cause server to send invalid data encoding to client
@ 2021-07-14 11:49 Antoine <plaskowski.stanislas@gmail.com>
  2021-07-14 13:50 ` Re: Windows locale cause server to send invalid data encoding to client Julien Rouhaud <rjuju123@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Antoine @ 2021-07-14 11:49 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org

I set up a postgresql server on Windows 10 and connected it using Rust, but
the Rust client reports invalid UTF-8 data when the password is wrong. I
use a french locale windows that contain some accents "éèê" etc.

Windows use WTF-16 <https://simonsapin.github.io/wtf-8/; but the Rust
client asks UTF-8 to the serveur so we think it's a bug from the server to
not send UTF-8 even if Windows doesn't use it for its locale translation.

Details can be found at this github issue #803
<https://github.com/sfackler/rust-postgres/issues/803;. Here a recorded
wireshark of the problem  output.pcapng.gz
<https://github.com/sfackler/rust-postgres/files/6797262/output.pcapng.gz;.

The version is: `psql (PostgreSQL) 13.3`

I never used a mailing list so I'm not used to it.

-- 
La Terre est le berceau de l'humanité mais qui voudrait passer sa vie dans
un berceau.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Windows locale cause server to send invalid data encoding to client
  2021-07-14 11:49 Windows locale cause server to send invalid data encoding to client Antoine <plaskowski.stanislas@gmail.com>
@ 2021-07-14 13:50 ` Julien Rouhaud <rjuju123@gmail.com>
  2021-07-14 14:19   ` Re: Windows locale cause server to send invalid data encoding to client Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Julien Rouhaud @ 2021-07-14 13:50 UTC (permalink / raw)
  To: Antoine <plaskowski.stanislas@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org

On Wed, Jul 14, 2021 at 01:49:24PM +0200, Antoine wrote:
> I set up a postgresql server on Windows 10 and connected it using Rust, but
> the Rust client reports invalid UTF-8 data when the password is wrong. I
> use a french locale windows that contain some accents "éèê" etc.
> 
> Windows use WTF-16 <https://simonsapin.github.io/wtf-8/; but the Rust
> client asks UTF-8 to the serveur so we think it's a bug from the server to
> not send UTF-8 even if Windows doesn't use it for its locale translation.

This is unfortunately working as designed.  The client encoding can't be set
during startup (and authentication is part of it), see
https://github.com/postgres/postgres/blob/master/src/backend/utils/mb/mbutils.c#L85-L88
for more details about it:

> /*
>  * During backend startup we can't set client encoding because we (a)
>  * can't look up the conversion functions, and (b) may not know the database
>  * encoding yet either.  So SetClientEncoding() just accepts anything and
>  * remembers it for InitializeClientEncoding() to apply later.
>  */

The driver should be prepared to receive non UTF-8 messages until
authentication succeeded.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Windows locale cause server to send invalid data encoding to client
  2021-07-14 11:49 Windows locale cause server to send invalid data encoding to client Antoine <plaskowski.stanislas@gmail.com>
  2021-07-14 13:50 ` Re: Windows locale cause server to send invalid data encoding to client Julien Rouhaud <rjuju123@gmail.com>
@ 2021-07-14 14:19   ` Tom Lane <tgl@sss.pgh.pa.us>
  2021-07-14 14:32     ` Re: Windows locale cause server to send invalid data encoding to client Julien Rouhaud <rjuju123@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2021-07-14 14:19 UTC (permalink / raw)
  To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: Antoine <plaskowski.stanislas@gmail.com>; pgsql-bugs@lists.postgresql.org

Julien Rouhaud <rjuju123@gmail.com> writes:
> On Wed, Jul 14, 2021 at 01:49:24PM +0200, Antoine wrote:
>> I set up a postgresql server on Windows 10 and connected it using Rust, but
>> the Rust client reports invalid UTF-8 data when the password is wrong. I
>> use a french locale windows that contain some accents "éèê" etc.

> This is unfortunately working as designed.  The client encoding can't be set
> during startup (and authentication is part of it), see
> https://github.com/postgres/postgres/blob/master/src/backend/utils/mb/mbutils.c#L85-L88
> for more details about it:

It seems like the core problem is that the "authentication failed" error
text may be sent in an unexpected encoding.  I wonder if we should decline
to translate any error messages until we've established the requested
client encoding.  Sending the message in English isn't ideal either,
but it'd avoid this hazard.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Windows locale cause server to send invalid data encoding to client
  2021-07-14 11:49 Windows locale cause server to send invalid data encoding to client Antoine <plaskowski.stanislas@gmail.com>
  2021-07-14 13:50 ` Re: Windows locale cause server to send invalid data encoding to client Julien Rouhaud <rjuju123@gmail.com>
  2021-07-14 14:19   ` Re: Windows locale cause server to send invalid data encoding to client Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-07-14 14:32     ` Julien Rouhaud <rjuju123@gmail.com>
  2021-07-14 14:43       ` Re: Windows locale cause server to send invalid data encoding to client Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Julien Rouhaud @ 2021-07-14 14:32 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Antoine <plaskowski.stanislas@gmail.com>; pgsql-bugs@lists.postgresql.org

On Wed, Jul 14, 2021 at 10:19:59AM -0400, Tom Lane wrote:
> 
> I wonder if we should decline
> to translate any error messages until we've established the requested
> client encoding.  Sending the message in English isn't ideal either,
> but it'd avoid this hazard.

I'm not sure which one is the worst.  One the bright side there aren't that
many messages that can be sent until the client encoding can be set up for I'm
+0.5 for this change.

I don't think this would be back patchable right?  In any case it won't help
existing servers, so drivers won't benefit from such a change before many
years :(





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Windows locale cause server to send invalid data encoding to client
  2021-07-14 11:49 Windows locale cause server to send invalid data encoding to client Antoine <plaskowski.stanislas@gmail.com>
  2021-07-14 13:50 ` Re: Windows locale cause server to send invalid data encoding to client Julien Rouhaud <rjuju123@gmail.com>
  2021-07-14 14:19   ` Re: Windows locale cause server to send invalid data encoding to client Tom Lane <tgl@sss.pgh.pa.us>
  2021-07-14 14:32     ` Re: Windows locale cause server to send invalid data encoding to client Julien Rouhaud <rjuju123@gmail.com>
@ 2021-07-14 14:43       ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2021-07-14 14:43 UTC (permalink / raw)
  To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: Antoine <plaskowski.stanislas@gmail.com>; pgsql-bugs@lists.postgresql.org

Julien Rouhaud <rjuju123@gmail.com> writes:
> On Wed, Jul 14, 2021 at 10:19:59AM -0400, Tom Lane wrote:
>> I wonder if we should decline
>> to translate any error messages until we've established the requested
>> client encoding.  Sending the message in English isn't ideal either,
>> but it'd avoid this hazard.

> I'm not sure which one is the worst.  One the bright side there aren't that
> many messages that can be sent until the client encoding can be set up for I'm
> +0.5 for this change.

Yeah, it's ugly either way.  I think though that the reason we don't hear
more complaints about this is that such messages are currently sent using
the language and encoding derived from the postmaster's environment.
In simple cases that'll be the same as the client's environment and
everything works.  So after thinking harder, I'm afraid that breaking that
scenario would make this idea a net loss.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2021-07-14 14:43 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 11:49 Windows locale cause server to send invalid data encoding to client Antoine <plaskowski.stanislas@gmail.com>
2021-07-14 13:50 ` Julien Rouhaud <rjuju123@gmail.com>
2021-07-14 14:19   ` Tom Lane <tgl@sss.pgh.pa.us>
2021-07-14 14:32     ` Julien Rouhaud <rjuju123@gmail.com>
2021-07-14 14:43       ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox