From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6960 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: [PATCH] linedit, deluser: use POSIX getpwent instead of getpwent_r Date: Mon, 9 Feb 2015 13:20:43 -0500 Message-ID: <20150209182043.GF23507@brightrain.aerifal.cx> References: <1398411394-19971-1-git-send-email-ncopa@alpinelinux.org> <20150205184601.GK23507@brightrain.aerifal.cx> <20150205205224.GN23507@brightrain.aerifal.cx> <20150207013229.GT23507@brightrain.aerifal.cx> <20150207165219.GB23507@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1423506064 18934 80.91.229.3 (9 Feb 2015 18:21:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Feb 2015 18:21:04 +0000 (UTC) Cc: musl@lists.openwall.com To: M Farkas-Dyck Original-X-From: musl-return-6973-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 09 19:21:04 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YKsxA-0004u2-HO for gllmg-musl@m.gmane.org; Mon, 09 Feb 2015 19:21:00 +0100 Original-Received: (qmail 1829 invoked by uid 550); 9 Feb 2015 18:20:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1821 invoked from network); 9 Feb 2015 18:20:59 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6960 Archived-At: On Mon, Feb 09, 2015 at 01:05:07PM -0500, M Farkas-Dyck wrote: > On 07/02/2015, Rich Felker wrote: > > On Sat, Feb 07, 2015 at 03:14:10PM +0100, Denys Vlasenko wrote: > >> On Sat, Feb 7, 2015 at 2:32 AM, Rich Felker wrote: > >> >> > the _r functions are for thread-safe > >> >> > versions of their corresponding legacy functions, but getpwent_r has > >> >> > inherent global state -- the iterator. Whoever made it just wasn't > >> >> > thinking. To make a correct interface like this the caller would > >> >> > need > >> >> > to have an iterator object to pass to the function, but I can't see > >> >> > much merit in inventing a new interface for this. > > buf may contain arbitrary data, yes? If so we could store the iterator there. No. On entry the buffer must be assumed to be uninitialized. The caller could be passing a completely new buffer each time, and even if not, on the first call the buffer is going to contain junk. The contract of getpwent_r, at least on glibc and compatible systems, seems to be that it uses the same iterator as getpwent. But since it turns out there are multiple incompatible historical functions names getpwent_r that all behave differently, this proposal has basically been shelved anyway. Busybox has dropped its use of getpwent_r. Rich