From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1555 Path: news.gmane.org!not-for-mail From: "Ivan Kanakarakis" Newsgroups: gmane.linux.lib.musl.general Subject: Re: getpwent.c: isn't line supposed to be set NULL? Date: Mon, 13 Aug 2012 13:29:38 +0300 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Trace: dough.gmane.org 1344853804 23660 80.91.229.3 (13 Aug 2012 10:30:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 13 Aug 2012 10:30:04 +0000 (UTC) To: musl@lists.openwall.com, "Arvid E. Picciani" Original-X-From: musl-return-1556-gllmg-musl=m.gmane.org@lists.openwall.com Mon Aug 13 12:30:04 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1T0ruE-0005sn-Jr for gllmg-musl@plane.gmane.org; Mon, 13 Aug 2012 12:29:54 +0200 Original-Received: (qmail 10093 invoked by uid 550); 13 Aug 2012 10:29:53 -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 10085 invoked from network); 13 Aug 2012 10:29:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=JvS7m+UZdwruzbsSg3NaJy29jJuTQb5XC7GpafO0urk=; b=bjtF2mi8yIUZ2yecBBsXKvRNBVbrV4tiQaD3L0bKOTrJsPQYlzVl5K3cbMmsSISmE7 gFGHX3aCf+VppuIb5KsM79sFTdU3hYHXZtttYF7100XiXIXjmqubigIvuXANVxdXmFNi rZlyAdQFfobR0xsyE9pqZziIdduk96tdAR+mg7NiMND6al1me2ipKAXNrKrEg4yGpMja 3jLzFFB5Nwv3xb8YUPKieSsqVjrzXG8zG5JO/xazApi3MyNJ9D9IwIQlWirTFbp3yn+J X0+jqztvl8wgkj1ZB9M4dVER1nKt1FicYQun42Q5YCtwc/bYStKCrboKDkpjdy5NjIoI unuQ== In-Reply-To: User-Agent: Opera Mail/12.01 (Linux) Xref: news.gmane.org gmane.linux.lib.musl.general:1555 Archived-At: On Mon, 13 Aug 2012 13:04:14 +0300, Arvid E. Picciani wro= te: > the getpw* functions call getline in a dubious way > for example: > > struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, = > size_t *size) > [..] > if ((l=3Dgetline(line, size, f)) < 0) { > free(*line); > *line =3D 0; > > > is called from > > struct passwd *fgetpwent(FILE *f) > [..] > static char *line; per standard: All objects with static storage duration shall be initialized (set to = their initial values) before program startup. This initialization applies to all objects having =EF=AC=81le scope and = objects in = block scope that have internal linkage. The initial values may have been provided explicitly by the = developer or implicitly by the implementation. Once set, these objects are never reinitialized again during the current= = program invocation, even if main is called recursively (permitted in C90, but not in C99 or C++) As line is static, there is no need for explicit initialization ('char = *line =3D 0;'). > return __getpwent_a(f, &pw, &line, &size); > > > where line is uninitialized. > > first thing getdelim (forwarded from getline) does is: > > if (!*s) *n=3D0; > > so this looks wrong somewhere. > maybe i'm just missing an =3D0 in between. > > -- = Ivan c00kiemon5ter Kanakarakis