From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7575 Path: news.gmane.org!not-for-mail From: Kevin Bowling Newsgroups: gmane.linux.lib.musl.general Subject: fgetgrent_a questions/review Date: Thu, 7 May 2015 05:53:43 -0700 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf303f64d0c9220205157d662e X-Trace: ger.gmane.org 1431003250 3624 80.91.229.3 (7 May 2015 12:54:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 May 2015 12:54:10 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7588-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 07 14:54:07 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 1YqLJW-0006fC-E8 for gllmg-musl@m.gmane.org; Thu, 07 May 2015 14:54:06 +0200 Original-Received: (qmail 3188 invoked by uid 550); 7 May 2015 12:53: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 3147 invoked from network); 7 May 2015 12:53:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kev009.com; s=google; h=mime-version:date:message-id:subject:from:to:content-type; bh=Hwsjs7ddxS/vDetghEcI1jiOIVkFUk+JoKQSrpxtkR4=; b=mjvk5VzdwRUBLYq2Otg0LCC2C4Q6ZcKgwZP3A7pAHle/EUyKrKuxtaY314HKLVygXi wJ6bbkBz3VkYiiL1aF/CyMvfzDXIUde1GPkQHJMy3fbWg0iOH0s8AzMvzLX6cqUHorlo ecC1bZyUSwXhgVdsSO+Z1slM4y73BWx2Cqhho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=Hwsjs7ddxS/vDetghEcI1jiOIVkFUk+JoKQSrpxtkR4=; b=lmDiqf3QT5DG3yC7mMBm9poN+Jz3bd1QoQOxCu6OSCG5zM5h60LGGi4fDdYPJTINnQ gh8iNShQ/5GYRELfTGMNNsZUaSHEKuNOcz4r5O7pqk1SXyInJ+c+97bVIdorL0gjtMXY 8EWk9jgrzNxdfJ5pZ9Ryvi272G4greu/b1DfBIcozfMFhI8Xniuwn3amSPjClapTSLC5 53eeW/xc+SVfDwaB+CFtbfvZbbgqLpg/pLUCjg9C/otkKAmCUEvyx0e44udNual5yjFn NDuolFM+DedXupVgkxW6RSxnAaVU3mVkPnszDRrk8z2rZP5GLJBRNGuPLzG1Wq3cFBg9 JKyw== X-Gm-Message-State: ALoCoQkOlGunRcyCo1+s1qoc5wCPa74e3X6reQ+3BSpyNCXU7h0xygs0MrQS9qH4y6tQ9Ec2CfLX X-Received: by 10.42.206.9 with SMTP id fs9mr3372670icb.19.1431003223081; Thu, 07 May 2015 05:53:43 -0700 (PDT) Xref: news.gmane.org gmane.linux.lib.musl.general:7575 Archived-At: --20cf303f64d0c9220205157d662e Content-Type: text/plain; charset=UTF-8 Hi, I borrowed the fget*ent_a functions to port libnss-cache to FreeBSD because the fgetent family of functions are not standard and the musl implementations looked clean and compact with a good license. https://github.com/google/libnss-cache/pull/1/files#diff-800bf143f84497855c6338a07c19b4af I had to make a few changes which may be suitable for musl. First, getline seems to resize the buffer as it pleases but this causes problems since the glibc implementation uses fgets and generally something higher up the call stack handles the resizing. Second, the current musl implementation doesn't return ERANGE which was necessary to get the caller's (nsswitch) code to do the right thing to the buffer. Finally, I wasn't quite sure what to do with mem and nmem in this case. I made mem static, and pass nmem in in a wrapper function.. but I do not know if these are allocated and freed correctly used standalone like this? Regards, Kevin --20cf303f64d0c9220205157d662e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I borrowed the fget*ent_a funct= ions to port libnss-cache to FreeBSD because the fgetent family of function= s are not standard and the musl implementations looked clean and compact wi= th a good license.

https://github.com/goo= gle/libnss-cache/pull/1/files#diff-800bf143f84497855c6338a07c19b4af
=
I had to make a few changes which may be suitable for musl.=C2=A0= First, getline seems to resize the buffer as it pleases but this causes pr= oblems since the glibc implementation uses fgets and generally something hi= gher up the call stack handles the resizing.=C2=A0 Second, the current musl= implementation doesn't return ERANGE which was necessary to get the ca= ller's (nsswitch) code to do the right thing to the buffer.
Finally, I wasn't quite sure what to do with mem and nmem i= n this case.=C2=A0 I made mem static, and pass nmem in in a wrapper functio= n.. but I do not know if these are allocated and freed correctly used stand= alone like this?

Regards,
Kevin
--20cf303f64d0c9220205157d662e--