Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i1u3m-0001C5-KY for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Aug 2019 15:04: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 1i1u2n-0005UP-6m for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Aug 2019 15:03:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i1u2m-0005UI-RQ for pgsql-hackers@lists.postgresql.org; Sun, 25 Aug 2019 15:03: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_SHA1:256) (Exim 4.92) (envelope-from ) id 1i1u2k-0006Pq-Hv for pgsql-hackers@postgresql.org; Sun, 25 Aug 2019 15:02: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 x7PF2W0K014043; Sun, 25 Aug 2019 11:02:32 -0400 From: Tom Lane To: Quentin Rameau cc: pgsql-hackers@postgresql.org Subject: Re: [PATCH] Fix missing argument handling in psql getopt In-reply-to: <20190825100617.GA6087@fifth.space> References: <20190825100617.GA6087@fifth.space> Comments: In-reply-to Quentin Rameau message dated "Sun, 25 Aug 2019 12:06:17 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14041.1566745352.1@sss.pgh.pa.us> Date: Sun, 25 Aug 2019 11:02:32 -0400 Message-ID: <14042.1566745352@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Quentin Rameau writes: > When passing an argument option with a missing argument, strcmp would > be called with the argv terminating NULL. Um ... so how would control get there with optind too large? What test case/platform are you considering? (There really shouldn't be *any* case where getopt advances optind past argc, imo.) regards, tom lane