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 1kCz2p-0004Yh-9w for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2020 05:41:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kCz2n-0002pQ-PA for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2020 05:41:21 +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 1kCz2n-0002pI-I6 for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2020 05:41:21 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kCz2g-0001Ps-L9 for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2020 05:41:21 +0000 Received: from hnk.local (p12054-ipngn2901funabasi.chiba.ocn.ne.jp [153.212.171.54]) by oss.nttdata.com (Postfix) with ESMTPSA id A41F662362; Tue, 1 Sep 2020 14:41:09 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com Subject: Re: Remove line length restriction in passwordFromFile() From: Fujii Masao To: Tom Lane , pgsql-hackers@lists.postgresql.org Cc: Fujii Masao References: <4187382.1598909041@sss.pgh.pa.us> <90aed8c6-a171-4cf7-4e4a-0d4d9593f6c5@oss.nttdata.com> Message-ID: Date: Tue, 1 Sep 2020 14:41:09 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <90aed8c6-a171-4cf7-4e4a-0d4d9593f6c5@oss.nttdata.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020/09/01 10:00, Fujii Masao wrote: > > > On 2020/09/01 6:24, Tom Lane wrote: >> Per the discussion at [1], we're now aware of actual use-cases for >> password strings approaching a kilobyte in length.  I think this puts >> the final nail in the coffin of the idea that passwordFromFile() can >> use a fixed-length line buffer.  Therefore, commit 2eb3bc588 (which >> added a warning for overlength lines) seems rather misguided in >> hindsight.  What we should do instead is fix that code so it has no >> hard upper bound on the line length. > > AFAIR, there were proposals to increase the maximum length of password so far, > but we could not do that because we failed to get the consensus about > that change. But if we get the clear use-case requiring longer password and > reach the consensus, that's good news. I agree with the change. > >> Even if you want to say that >> we'll set a particular limit on how long the password field can be, >> there's no good upper bound for the length of the hostname field; >> so ISTM that just getting out of the business of a fixed-size buffer >> is the sanest way. >> >> Hence, the attached proposed patch does that, and for good measure >> adds some testing of this formerly untested code. The patch looks good to me, except the following minor thing. + if (fgets(buf.data + buf.len, buf.maxlen - buf.len - 1, fp) == NULL) IIUC fgets() reads the data with the specified size - 1, so ISTM that -1 of "buf.maxlen - buf.len - 1" is not necessary. Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION