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 1lRzQ9-0000mq-MX for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Apr 2021 15:39:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lRzQ8-0008JC-6x for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Apr 2021 15:39:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRzQ7-0008FN-VQ for pgsql-bugs@lists.postgresql.org; Thu, 01 Apr 2021 15:39:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRzQ5-00035Q-6D for pgsql-bugs@lists.postgresql.org; Thu, 01 Apr 2021 15:39:42 +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 131FdXqA3413026; Thu, 1 Apr 2021 11:39:33 -0400 From: Tom Lane To: Sergey KOPOSOV cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #16951: pg_restore segfaults on custom format piped from a different version of PG In-reply-to: <51cec7215378e9beccb9b58831f6e0a2be30bd06.camel@ed.ac.uk> References: <16951-a4dd68cf0de23048@postgresql.org> <3331060.1617226031@sss.pgh.pa.us> <5d848bddbb3b6421af5a742e36ede542e719c492.camel@ed.ac.uk> <3338139.1617230824@sss.pgh.pa.us> <51cec7215378e9beccb9b58831f6e0a2be30bd06.camel@ed.ac.uk> Comments: In-reply-to Sergey KOPOSOV message dated "Thu, 01 Apr 2021 13:05:44 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3413024.1617291573.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 01 Apr 2021 11:39:33 -0400 Message-ID: <3413025.1617291573@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sergey KOPOSOV writes: > Importantly This requires running pg_restore without '-Fc' flag, i.e. to= let it autodetect. > $ cat /tmp/xx1.short | ./src/bin/pg_dump/pg_restore > Segmentation fault (core dumped) > $ cat /tmp/xx1.short | ./src/bin/pg_dump/pg_restore -Fc > pg_restore: [archiver] unsupported version (1.14) in file header Ooooh ... the autodetect + cant-seek code path is just broken. All of the sanity checks on the first few fields of the file --- particularly the version number --- just get skipped in this scenario. I wonder why it's a good idea to read-ahead any of those fields in the first place. Checking the PGDMP magic string seems sufficient. Will fix, thanks for the report! regards, tom lane