Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: coredump completing scp
On Sat, 29 Jan 2011 21:51:02 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author