Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7mcY-0000vk-V8 for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Jan 2022 23:01:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n7mcX-0005UU-Bh for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Jan 2022 23:01:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n7mcX-0005UK-1B for pgsql-hackers@lists.postgresql.org; Wed, 12 Jan 2022 23:01:33 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n7mcP-0005L6-V2 for pgsql-hackers@lists.postgresql.org; Wed, 12 Jan 2022 23:01:32 +0000 Received: from [192.168.31.120] (unknown [62.217.188.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 7501A21C2ED6; Thu, 13 Jan 2022 02:01:24 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1642028484; bh=eGgaJmECWRpQqW5pqsXueqHnVZTq5sszDGgcJza6Qjw=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=enAdqt/1Zc5M7daFVgG/WeguDpnXt9CxV+ndDeeIbiVDh25UxUfUymyPuJIo9iAD8 dGrHOQxGLu2DheSK2zzVmV68t/eXSeYjG75JVAAXvZcH1roNsdbbDtGPpytwmrltss 6b31DI8uocR9gidyZN6K7xjbzoF0dRwLW5vaxdnA= Content-Type: multipart/mixed; boundary="------------bHkMCJ9ySppfgidwal8hsheE" Message-ID: <8cbb56dd-63d6-a581-7a65-25a97ac4be03@postgrespro.ru> Date: Thu, 13 Jan 2022 02:01:24 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: Re: Improve error handling of HMAC computations and SCRAM Content-Language: en-US To: Michael Paquier Cc: Postgres hackers References: <066c0624-fbb7-a025-afd6-d54683a96947@postgrespro.ru> <71b9a5d2-a3bf-83bc-a243-93dcf0bcfb3b@postgrespro.ru> From: Sergey Shinderuk In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------bHkMCJ9ySppfgidwal8hsheE Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12.01.2022 14:32, Michael Paquier wrote: > On Wed, Jan 12, 2022 at 12:56:17PM +0900, Michael Paquier wrote: >> Attached is a rebased patch for the HMAC portions, with a couple of >> fixes I noticed while going through this stuff again (mostly around >> SASLprep and pg_fe_scram_build_secret), and a fix for a conflict >> coming from 9cb5518. psql's \password is wrong to assume that the >> only error that can happen for scran-sha-256 is an OOM, but we'll get >> there. > > With an attachment, that's even better. (Thanks, Daniel.) Gave it a thorough read. Looks good, except for errstr not set in a couple of places (see the diff attached). Didn't test it. -- Sergey Shinderuk https://postgrespro.com/ --------------bHkMCJ9ySppfgidwal8hsheE Content-Type: text/plain; charset=UTF-8; name="errstr-not-set.txt" Content-Disposition: attachment; filename="errstr-not-set.txt" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy9jb21tb24vaG1hYy5jIGIvc3JjL2NvbW1vbi9obWFjLmMKaW5k ZXggNTkyZjliMjBhMzguLmEyNzc3OGU4NmIzIDEwMDY0NAotLS0gYS9zcmMvY29tbW9uL2ht YWMuYworKysgYi9zcmMvY29tbW9uL2htYWMuYwpAQCAtNDYsOSArN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