Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wBzKu-001YuE-1f for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Apr 2026 18:15:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wBzKs-002xeN-2I for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Apr 2026 18:15:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wBzKs-002xeF-1O for pgsql-hackers@lists.postgresql.org; Sun, 12 Apr 2026 18:15:07 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wBzKr-00000000fr5-00Vm; Sun, 12 Apr 2026 18:15:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 63CIF0mq342869; Sun, 12 Apr 2026 14:15:00 -0400 From: Tom Lane To: Etsuro Fujita cc: Corey Huinker , Ashutosh Bapat , Michael Paquier , pgsql-hackers@postgresql.org, jkatz@postgresql.org, nathandbossart@gmail.com Subject: Re: Import Statistics in postgres_fdw before resorting to sampling. In-reply-to: References: message dated "Wed, 08 Apr 2026 20:24:00 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <342867.1776017700.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 12 Apr 2026 14:15:00 -0400 Message-ID: <342868.1776017700@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Etsuro Fujita writes: > Pushed. I closed the CF entry as well. Coverity doesn't like this patch's uses of strncpy(): >>> CID 1691464: (BUFFER_SIZE) >>> Calling "strncpy" with a maximum size argument of 64 bytes on dest= ination array "remattrmap[attrcnt].local_attname" of size 64 bytes might l= eave the destination string unterminated. 5960 strncpy(remattrmap[attrcnt].local_attname, attname, NAMEDATALEN= ); 5961 strncpy(remattrmap[attrcnt].remote_attname, remote_attname, NAM= EDATALEN); I think it's dead right to complain: remote_attname, in particular, could certainly be longer than NAMEDATALEN. AFAICS, postgres_fdw's subsequent uses of those strings only need them to be nul-terminated C strings, so strncpy's property of zero-filling the whole buffer is not needed here. I recommend s/strncpy/strlcpy/. It's probably also appropriate to think about using pg_mbcliplen() to ensure that this code doesn't result in a broken multibyte character. regards, tom lane