From owner-freebsd-hackers Mon Feb 19 9:23:53 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from earth.backplane.com (earth-nat-cw.backplane.com [208.161.114.67]) by hub.freebsd.org (Postfix) with ESMTP id 1063637B401 for ; Mon, 19 Feb 2001 09:23:51 -0800 (PST) Received: (from dillon@localhost) by earth.backplane.com (8.11.2/8.9.3) id f1JHNII37074; Mon, 19 Feb 2001 09:23:18 -0800 (PST) (envelope-from dillon) Date: Mon, 19 Feb 2001 09:23:18 -0800 (PST) From: Matt Dillon Message-Id: <200102191723.f1JHNII37074@earth.backplane.com> To: "Andrey Simonenko" Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Staticaly allocated buffers in library. Is it correct? References: <96rash$1m1d$1@igloo.uran.net.ua> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG : :So, if I send problem report with my patches, I should inherit usage of :staticaly allocated buffers. :Am I right? : :milunovic wrote in message :news:Pine.BSF.4.21.0102171202110.400-100000@scorpion.cosmos.all.net... :> -----BEGIN PGP SIGNED MESSAGE----- :> :> On Fri, 16 Feb 2001, Andrey Simonenko wrote: :> :> > I patched some library files and noted that some functions, which parse :some :> > configuration files, use staticaly allocated buffers. Sizes of such :> > staticaly allocated buffers are 8k, 10k and so on. These buffers are :used to :> > hold one line from parsed file. Usually it is enough for one line, but :... Yes. System libraries traditionally use statically allocated buffers because, even now, there is no dynamic equivalent for fgets(). The closest you can get is to mmap() the file and extract the lines that way. But as long as the buffer sizes are reasonable and the library uses fgets() with the proper length limitation, using a statically allocated buffer is not a big deal. Most configuration files couldn't have long lines and still be legal anyway. -Matt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message