If a single header is more than 200 characters long a set of 'off by
one' errors cause memory corruption.
When allocating memory with:
a = malloc (len);
the last usable byte of the memory is 'a + len - 1' rather than 'a +
len'.
Fix the same bug when calculating the current offset should the buffer
used for collecting the output header need to be reallocated.
headers->lineptr = headers->line = malloc (headers->line_size);
}
lineptr = headers->lineptr;
- lineend = headers->line + headers->line_size;
+ lineend = headers->line + headers->line_size - 1;
if (lineptr == NULL)
return;
outptr = filter->outbuf;
if (lineptr == lineend) {
headers->line_size *= 2;
headers->line = xrealloc (headers->line, headers->line_size);
- lineptr = headers->line + headers->line_size / 2;
- lineend = headers->line + headers->line_size;
+ lineptr = headers->line + (headers->line_size / 2) - 1;
+ lineend = headers->line + headers->line_size - 1;
}
if (headers->saw_nl && *inptr != ' ' && *inptr != '\t') {