From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20442 invoked by alias); 15 Feb 2011 19:03:27 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28763 Received: (qmail 8139 invoked from network); 15 Feb 2011 19:02:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.48 as permitted sender) Date: Tue, 15 Feb 2011 19:02:48 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: coredump completing scp Message-ID: <20110215190248.00c834f2@pws-pc.ntlworld.com> In-Reply-To: <110129215102.ZM21791@torch.brasslantern.com> References: <201101292216.p0TMGPm2003261@pws-pc.ntlworld.com> <110129151306.ZM7899@torch.brasslantern.com> <20110129233358.0e33fee1@pws-pc.ntlworld.com> <110129215102.ZM21791@torch.brasslantern.com> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.0; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.1 cv=JvdXmxIgLJv2/GthKqHpGJEEHukvLcvELVXUanXFreg= c=1 sm=0 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=NLZqzBF-AAAA:8 a=Jj-65wo3zlshEaDlDmEA:9 a=y4VOK8qA-Yjxiqe0nNUA:7 a=5e1ZQon6yFipS0dfycoGuISUBykA:4 a=CjuIK1q_8ugA:10 a=I6wTmPyJxzYA:10 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 On Sat, 29 Jan 2011 21:51:02 -0800 Bart Schaefer wrote: > On Jan 29, 11:33pm, Peter Stephenson wrote: > } Subject: Re: coredump completing scp > } > } On Sat, 29 Jan 2011 15:13:06 -0800 > } Bart Schaefer wrote: > } > It may be that setpwent() assumes that getpwent() has allocated something > } > } Right, and since we always call endpwent() after all uses of getpwent(), > } we're guaranteed not to need setpwent() at all, aren't we? > > It's probably defensive programming against getpwent() having been used > by a module or library without being endpwent()d afterward. While that doesn't seem all that useful at the moment, we could cover all the bases by attempt to read from the database before we rewind it. Index: Src/hashtable.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v retrieving revision 1.32 diff -p -u -r1.32 hashtable.c --- Src/hashtable.c 21 Sep 2009 09:22:23 -0000 1.32 +++ Src/hashtable.c 15 Feb 2011 19:00:21 -0000 @@ -1339,6 +1339,12 @@ fillnameddirtable(UNUSED(HashTable ht)) #ifdef HAVE_GETPWENT struct passwd *pw; + /* + * setpwent() rewinds the database. Apparently some + * implementations have problems if the database wasn't + * read, so perform a dummy read first. + */ + (void)getpwent(); setpwent(); /* loop through the password file/database * @@ -1379,6 +1385,12 @@ fillnameddirtable(UNUSED(HashTable ht)) #ifdef USE_GETPWENT struct passwd *pw; + /* + * setpwent() rewinds the database. Apparently some + * implementations have problems if the database wasn't + * read, so perform a dummy read first. + */ + (void)getpwent(); setpwent(); /* loop through the password file/database * -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/