Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Message-ID: <436E50DE.3070405@cwilson.fastmail.fm>
Date: Sun, 06 Nov 2005 13:52:14 -0500
From: Charles Wilson <cygwin@cwilson.fastmail.fm>
User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: BUG: alternatives
References: <436CF5E9.30106@cwilson.fastmail.fm> <001201c5e244$c9e50490$020aa8c0@DFW5RB41> <436D9993.7050100@cwilson.fastmail.fm> <20051106134339.GA24549@trixie.casa.cgf.cx>
In-Reply-To: <20051106134339.GA24549@trixie.casa.cgf.cx>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Christopher Faylor wrote:

> A signal shouldn't cause a truncated read when retrieving data from
> disk on cygwin or linux.

ACK.

> I think the only sane way to handle this is to put the read in a loop
> and realloc the buffer as needed as long as the read continues to return
> '>0'.

Ok.

> It's obviously pretty racy to get the size of the file and then expect that
> you'll be able to read in exactly that many bytes.

ACK.

Revised patch attached.  I'm wondering, tho, about the advisability of 
using alloca'ed (rather than malloc'ed) memory to hold the contents of a 
file of unrestricted size.  Aren't there limits on the available space 
within a single stack frame?  Does it make sense (is it legal) to alloca 
40k or 50k or 500k? of memory?

Granted, most /var/lib/alternatives files are going to be fairly small 
(< 1k) but there's no guarantee of that...

--
Chuck


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

