Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: coredump completing scp



On Sat, 29 Jan 2011 15:13:06 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> This sure seems like a bug in setpwent(), but I'll note that we're making
> a call to setpwent() before ever calling getpwent() in the first place.
> The doc says:
> 
>    The setpwent() function effectively rewinds the user database to allow
>    repeated searches.
> 
> It may be that setpwent() assumes that getpwent() has allocated something
> that it needs to free, something which never has been allocated because
> getpwent() has never been called?  And that only the zsh-mem free() has
> a problem with this?

Right, and since we always call endpwent() after all uses of getpwent(),
we're guaranteed not to need setpwent() at all, aren't we?  My reading
is certainly that after endpwent() you're guaranteed to get the whole
thing from scratch next time, which is all we need.

--- ../zsh-git/zsh/Src/hashtable.c	2010-03-25 21:01:19.000000000 +0000
+++ Src/hashtable.c	2011-01-29 23:28:25.000000000 +0000
@@ -1339,8 +1339,6 @@ fillnameddirtable(UNUSED(HashTable ht))
 #ifdef HAVE_GETPWENT
 	    struct passwd *pw;
  
-	    setpwent();
- 
 	    /* loop through the password file/database *
 	     * and add all entries returned.           */
 	    while ((pw = getpwent()) && !errflag)
@@ -1379,8 +1377,6 @@ fillnameddirtable(UNUSED(HashTable ht))
 #ifdef USE_GETPWENT
 	struct passwd *pw;
  
-	setpwent();
- 
 	/* loop through the password file/database *
 	 * and add all entries returned.           */
 	while ((pw = getpwent()) && !errflag)

-- 
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