Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGg10-0004zB-8e for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Jun 2017 06:24:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dGg0z-0008S1-RV for pgsql-bugs@arkaria.postgresql.org; Fri, 02 Jun 2017 06:24:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dGg0I-0006NF-Eu for pgsql-bugs@postgresql.org; Fri, 02 Jun 2017 06:24:10 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dGg0F-0008TA-C9 for pgsql-bugs@postgresql.org; Fri, 02 Jun 2017 06:24:09 +0000 Received: by mail-lf0-x242.google.com with SMTP id v20so925393lfa.2 for ; Thu, 01 Jun 2017 23:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=AnkRY4+iMN5EnzzGNkDFBoHyPYXQT4NXDEXzQpwtNzM=; b=CvpphG8s5OM4OwnrTfTGFwFEjL6C20G9LKKUtjj2r/2T9ZUQM7d3T+aILz4l2fZxFW wAqQqFgGbmEBPTxuVMHCy2xueB7b3R+V7JGk9TFU+DymSEFosIJu5hye3U2kRqz68Tvq +gd3Y0/J0Lpm++bu39Ol9YIq78TzWnSdlDLwox837V+TW/uKRVGsTmR+vWKoGAsAqDHc 6tnuwKrUBMNfJdFGBgsBzzpr5dMbJrm+CoDWGQFEDgKl/4XInH2Mk5fgGLDrIQOnh8Yi JrA9eJc63EDYB2JGofoqE2m1yuPN/sAdDkWEOwAWr5EWLTHZ9Fx+9l6iiXuW2qw3blgM w/HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=AnkRY4+iMN5EnzzGNkDFBoHyPYXQT4NXDEXzQpwtNzM=; b=o1eKy6GNg2ko6npSarY4Qh2XPE5hiHwNRLlAKZUZjRmEMrHlfzvFg9oc2lsKI0vzZ5 Dn3P7KPdY66X3+auneks8E5SLt2u6bARrhLm9jBzQKnkL89J2NbFmEYNEmjXPrjlfhgE W9xaSUBkx42jWi9KqTdr7OJxPAVfJIj7hRQxT8oNu3Yx2uFfDvLJSSzv6QZkxEq4JpI5 VfhybvkQhnO1YO0jWoUzjG7V4U9IpTTQ6ay9GqLsLwUTq+IQW1VuBVOP9FQrw4ICpnyP /w62m0hhVMBKsRDTmkI99O5vxBDMyNIIFsZcg3w60DoZkuG6EZHn5Ws5YXslqeWGjAFT 1nnw== X-Gm-Message-State: AODbwcCoRiPnDL+xD2Dhym6lrInUwEEImGRLRRpVEl2VQYZddQAqeUBs HXeUwxlsca2sS6gD X-Received: by 10.25.89.78 with SMTP id n75mr1507633lfb.8.1496384644962; Thu, 01 Jun 2017 23:24:04 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-50df7f-241.dhcp.inet.fi. [80.223.127.241]) by smtp.gmail.com with ESMTPSA id h67sm4755098lfh.24.2017.06.01.23.24.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 23:24:04 -0700 (PDT) Subject: Re: [PATCH] Fixed malformed error message on malformed SCRAM message. To: Noah Misch , Michael Paquier References: <20170529214021.kaw5qjzsbofaa6re@alvherre.pgsql> <20170602055742.GA1502070@rfd.leadboat.com> Cc: Alvaro Herrera , Daniele Varrazzo , pgsql-bugs From: Heikki Linnakangas Message-ID: Date: Fri, 2 Jun 2017 09:24:02 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170602055742.GA1502070@rfd.leadboat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs