Mail Archives: djgpp-workers/2001/07/10/04:20:05
On Mon, 9 Jul 2001, Mark E. wrote:
> This patch adds buffer overflow checks to the output buffer. The
> idea is that a filename in the output buffer can't be valid and
> won't match if its size is greater or equal to 2000 bytes (or
> whatever impossible length).
Yes, I agree.
> + /* A pattern this big won't match any file. */
> + if (bp == pathbuf_end && *pp)
> + return 0;
I suggest "bp >= pathbuf_end" instead. In a deeply-recursive function
like this, you can never know ;-)
> glob(const char *_pattern, int _flags, int (*_errfunc)(const char *_epath,
> int _eerrno), glob_t *_pglob)
> {
> ! char path_buffer[PATHBUF_LEN + 1];
> int l_ofs, l_ptr;
>
> pathbuf = path_buffer+1;
> + pathbuf_end = path_buffer + PATHBUF_LEN;
Perhaps we should add a test against PATHBUF_LEN right here in `glob',
even before you start expanding.
- Raw text -