yyredo and yy_use_redo_text

Timo Sirainen tss at iki.fi
Sat May 10 08:28:24 CEST 2003


On Sat, 2003-05-10 at 04:54, David Relson wrote:
> The next time get_decoded_line() is called, yy_use_redo_text() will be 
> called to return the text in yysave.  At the time of this call, the "buff_t 
> *buff" parameter represents flex's buffer which has just been cleared by 
> the first function call (described above).  What's put into "buff" is 
> always less than what was there previously.
> 
> The code may be more complex than necessary (and likely is).  None the 
> less, it's safe.

Another way it's called is in buff_fill() which HTML comment stripper
calls. But it's still safe, because:

    while (size - leng > 2 && need > leng - used) {
	/* too few, read more */
	int add = get_decoded_line(buff);

It doesn't call get_decoded_line() unless avail is > 0..

And looking more at qp_decode(), it can write a few bytes more than it
was supposed to, but it's still safe because flex always allocates two
more bytes for \0\0, and you'll be overwriting those with \0 as well.

So, no real problems after all.





More information about the bogofilter-dev mailing list