|
Message-ID: <20150209182043.GF23507@brightrain.aerifal.cx> Date: Mon, 9 Feb 2015 13:20:43 -0500 From: Rich Felker <dalias@...c.org> To: M Farkas-Dyck <strake888@...il.com> Cc: musl@...ts.openwall.com Subject: Re: Re: [PATCH] linedit, deluser: use POSIX getpwent instead of getpwent_r On Mon, Feb 09, 2015 at 01:05:07PM -0500, M Farkas-Dyck wrote: > On 07/02/2015, Rich Felker <dalias@...c.org> 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 <dalias@...c.org> 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.