[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] getline bugfix submitted via findutils

From: Bruno Haible
Subject: Re: [Bug-gnulib] getline bugfix submitted via findutils
Date: Fri, 16 Apr 2004 21:56:58 +0200
User-agent: KMail/1.5

James Youngman wrote:
> Hence the enclosed patch may no longer be relevant to the current
> Gnulib code but I'm forwarding it to you guys in case it is useful.

This patch is garbage. If nchars_avail < 1, then nchars_avail must be 0.

> The problem occurs when getstr() is called with offset significantly greater
> than the the buffer size.

This is not allowed. The comment in getndelim2.h implies that the caller must
ensure that OFFSET <= *LINESIZE.

/* Read up to (and including) a delimiter DELIM1 from STREAM into *LINEPTR
   + OFFSET (and NUL-terminate it).  If DELIM2 is non-zero, then read up
   and including the first occurrence of DELIM1 or DELIM2.  *LINEPTR is
   a pointer returned from malloc (or NULL), pointing to *LINESIZE bytes of
   space.  It is realloc'd as necessary.  Reallocation is limited to
   NMAX bytes; if the line is longer than that, the extra bytes are read but
   thrown away.
   Return the number of bytes read and stored at *LINEPTR + OFFSET (not
   including the NUL terminator), or -1 on error or EOF.  */
extern ssize_t getndelim2 (char **lineptr, size_t *linesize, size_t nmax,
                           FILE *stream, int delim1, int delim2,
                           size_t offset);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]