patch for "invalid buffer size" problem.

David Relson relson at osagesoftware.com
Fri Jan 24 03:12:11 CET 2003


Greetings,

The patch below corrects the "Invalid buffer size, exiting" problem 
reported by several bogofilter 0.10.1 testers.  The code to kill html 
comments was attempting to keep the whole comment in the lexer's 
buffer.  This works - to a point.  On Linux the buffer size is 8192 bytes, 
so the code broke when a sufficiently long comment was present.  In the 
message I examined, there was a long style sheet.

The fix uses a simple expedient.  When processing a comment (for killing) 
and getting far into the buffer, kill the partial buffer and continue 
processing.

The patch is below.  Please test it and report your results.

Thank you.

David


Update of /cvsroot/bogofilter/bogofilter
In directory sc8-pr-cvs1:/tmp/cvs-serv5469

Modified Files:
	html.c
Log Message:
Fix buffering problem when killing html comments.

Index: html.c
===================================================================
RCS file: /cvsroot/bogofilter/bogofilter/html.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- html.c	24 Jan 2003 01:36:02 -0000	1.5
+++ html.c	24 Jan 2003 02:05:14 -0000	1.6
@@ -83,6 +83,15 @@
  	if (level == 0)
  	    break;
  	tmp += 1;
+	/* When killing html comments, there's no need to keep it in memory */
+	if (kill_html_comments && tmp - buf_start > 4000) {
+	    /* Leave enough to recognize the end of comment string. */
+	    byte *buf_temp = buf_used - COMMENT_END_LEN;
+	    size_t count = buf_temp - buf_start;
+	    memcpy(buf_start, buf_temp, buf_used - buf_temp);
+	    tmp -= count;
+	    buf_used -= count;
+	}
      }

      return buf_used - buf_start;




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
bogofilter-cvs mailing list
bogofilter-cvs at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bogofilter-cvs 





More information about the Bogofilter mailing list