Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0Bni-0004T9-M3 for pgsql-committers@arkaria.postgresql.org; Sun, 25 Mar 2018 19:59:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0Bnh-00011a-E8 for pgsql-committers@arkaria.postgresql.org; Sun, 25 Mar 2018 19:59:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0Bnh-00011R-9P for pgsql-committers@lists.postgresql.org; Sun, 25 Mar 2018 19:59:33 +0000 Received: from mail.thelabyrinth.net ([45.56.70.56]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0Bna-000806-7R for pgsql-committers@lists.postgresql.org; Sun, 25 Mar 2018 19:59:32 +0000 Received: from Davids-iMac.local (unknown [173.169.74.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dsteele) by mail.thelabyrinth.net (Postfix) with ESMTPSA id BD93B5466C; Sun, 25 Mar 2018 19:59:22 +0000 (UTC) Subject: Re: pgsql: Exclude unlogged tables from base backups To: Tom Lane Cc: Teodor Sigaev , pgsql-committers@lists.postgresql.org References: <14453.1522001792@sss.pgh.pa.us> <8d57c3ba-d44b-a8eb-7a91-c0b6156240fd@pgmasters.net> <3587.1522005723@sss.pgh.pa.us> <5114.1522007696@sss.pgh.pa.us> From: David Steele Message-ID: <182a8752-59d1-1f12-5f12-ccb6f7f5fc6e@pgmasters.net> Date: Sun, 25 Mar 2018 15:59:22 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <5114.1522007696@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/25/18 3:54 PM, Tom Lane wrote: > David Steele writes: >> On 3/25/18 3:22 PM, Tom Lane wrote: >>> Actually, that code didn't guarantee zero termination under *any* >>> circumstances; it only happened to work if the stack contained >>> zeroes to start with. > >> Interesting. strncpy() says it will pad the destination with NULLs when >> src is less than the size provided. Perhaps some compilers don't honor >> that? > > Yeah, but the "size provided" was the number of characters to be copied > from the source string, not the size of the destination buffer. So > strncpy didn't think it needed to add any nulls. There's a reason why > that function is widely disliked --- it's hard to use it in a safe way. Whoops, how right you are. I'm generally passing destination buffer size in these cases and totally misread what this was doing. -- -David david@pgmasters.net