zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: coredump completing scp
Date: Tue, 15 Feb 2011 19:02:48 +0000	[thread overview]
Message-ID: <20110215190248.00c834f2@pws-pc.ntlworld.com> (raw)
In-Reply-To: <110129215102.ZM21791@torch.brasslantern.com>

On Sat, 29 Jan 2011 21:51:02 -0800
Bart Schaefer <schaefer@brasslantern.com> 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 <schaefer@brasslantern.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


      reply	other threads:[~2011-02-15 19:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-28  3:13 Vin Shelton
2011-01-28  3:30 ` Bart Schaefer
2011-01-28  3:46   ` Vin Shelton
2011-01-28  9:56   ` Peter Stephenson
2011-01-28 10:14     ` Peter Stephenson
2011-01-29  1:42     ` Vin Shelton
2011-01-29 22:16       ` Peter Stephenson
2011-01-29 23:13         ` Bart Schaefer
2011-01-29 23:33           ` Peter Stephenson
2011-01-30  5:51             ` Bart Schaefer
2011-02-15 19:02               ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110215190248.00c834f2@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).