Re: [PATCH] Fixed malformed error message on malformed SCRAM message.

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Noah Misch <noah(at)leadboat(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [PATCH] Fixed malformed error message on malformed SCRAM message.
Date: 2017-06-02 06:24:02
Message-ID: a6b9fb83-284b-2e3e-66f1-75a78f8efce0@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 06/02/2017 08:57 AM, Noah Misch wrote:
> On Tue, May 30, 2017 at 04:39:55PM -0700, Michael Paquier wrote:
>> diff --git a/src/backend/libpq/auth-scram.c b/src/backend/libpq/auth-scram.c
>> index 99feb0ce94..366a11feb8 100644
>> --- a/src/backend/libpq/auth-scram.c
>> +++ b/src/backend/libpq/auth-scram.c
>> @@ -283,11 +283,13 @@ pg_be_scram_exchange(void *opaq, char *input, int inputlen,
>> if (inputlen == 0)
>> ereport(ERROR,
>> (errcode(ERRCODE_PROTOCOL_VIOLATION),
>> - (errmsg("malformed SCRAM message (empty message)"))));
>> + errmsg("malformed SCRAM message"),
>> + errdetail("The message is empty.")));
>> if (inputlen != strlen(input))
>> ereport(ERROR,
>> (errcode(ERRCODE_PROTOCOL_VIOLATION),
>> - (errmsg("malformed SCRAM message (length mismatch)"))));
>> + errmsg("malformed SCRAM message"),
>> + errdetail("Input length does not match.")));
>
> auth.c uses COMMERROR for this sort of thing; why does auth-scram.c use ERROR?

Yeah, COMMERROR would be more consistent. But I wonder why auth.c uses
COMMERROR rather than ERROR for these. It would seem more user-friendly.
Or developer-friendly; the most likely time you see these messages is
when you're developing a driver that speaks the protocol.

And pqformat.c uses ERROR for protocol violation errors. So we're not
very consistent. I think it would be best to convert all or most of the
ERRCODE_PROTOCOL_VIOLATION messages to ERROR. COMMERROR is appropriate
when you you think that the client has already disconnected, or is so
thoroughly confused that sending an error would just make things worse.
Or if you the message contains information that you don't want to reveal
to a non-authenticated client. I don't think that applies to any of the
COMMERRORs in auth.c.

- Heikki

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Noah Misch 2017-06-02 06:32:16 Re: [PATCH] Fixed malformed error message on malformed SCRAM message.
Previous Message Tom Lane 2017-06-02 06:20:00 Re: [PATCH] Fixed malformed error message on malformed SCRAM message.

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2017-06-02 06:31:44 Re: Why does logical replication launcher set application_name?
Previous Message Noah Misch 2017-06-02 06:22:58 Re: retry shm attach for windows (WAS: Re: OK, so culicidae is *still* broken)