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 1f0BjK-0004G2-JW for pgsql-committers@arkaria.postgresql.org; Sun, 25 Mar 2018 19:55:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0BjI-0000Ow-Ge for pgsql-committers@arkaria.postgresql.org; Sun, 25 Mar 2018 19:55:00 +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.89) (envelope-from ) id 1f0BjI-0000On-8F for pgsql-committers@lists.postgresql.org; Sun, 25 Mar 2018 19:55:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0BjF-0000hi-PH for pgsql-committers@lists.postgresql.org; Sun, 25 Mar 2018 19:54:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w2PJsu2J005115; Sun, 25 Mar 2018 15:54:56 -0400 From: Tom Lane To: David Steele cc: Teodor Sigaev , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Exclude unlogged tables from base backups In-reply-to: References: <14453.1522001792@sss.pgh.pa.us> <8d57c3ba-d44b-a8eb-7a91-c0b6156240fd@pgmasters.net> <3587.1522005723@sss.pgh.pa.us> Comments: In-reply-to David Steele message dated "Sun, 25 Mar 2018 15:46:48 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5113.1522007696.1@sss.pgh.pa.us> Date: Sun, 25 Mar 2018 15:54:56 -0400 Message-ID: <5114.1522007696@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. regards, tom lane