Subject: Re: ed segfault
To: Jachym Holecek <freza@dspfpga.com>
From: David Laight <david@l8s.co.uk>
List: tech-userlevel
Date: 06/09/2006 22:04:35
On Fri, Jun 09, 2006 at 09:56:25PM +0200, Jachym Holecek wrote:
> # hypnosses@pulltheplug.org 2006-06-09:
> > ed sefaults with a large string due to strcpy() below is a possible fix.
> 
> FWIW the below should be s/MAXPATHLEN - 1/MAXPATHLEN + 1/g, since
> old_filename is defined as "char old_filename[MAXPATHLEN + 1]" and
> strlcpy() should include the terminating NUL in size.

Using 'sizeof (old_filename)' is likely to be better.

OTOH just truncating the string brings in it's own bugs....

	David

-- 
David Laight: david@l8s.co.uk