limits [was: [cvs] ... token.c]
David Relson
relson at osagesoftware.com
Wed Apr 6 01:05:13 CEST 2005
On Wed, 06 Apr 2005 00:31:31 +0200
Matthias Andree wrote:
> David Relson <relson at users.sourceforge.net> writes:
>
> > + uint p = (prefix == NULL) ? 0 : prefix->leng;
> > + uint l = leng + p;
> > +
> > + if (l >= token_size)
> > + l = token_size - p;
> > +
> > + token->leng = l;
> > +
> > + /* copy prefix, if there is one */
> > + if (prefix != NULL)
> > + memcpy(token->text, prefix->text, p);
> > +
> > + memcpy(token->text + p, text, l-p); /* include nul terminator */
> > + token->text[token->leng] = '\0'; /* ensure nul termination */
>
> What is the upper limit here?
>
> IOW, against what limit does the actual prefix length count?
>
> Do we limit against MAXTOKENLEN or something a lot larger?
prefix->leng is the length of the current prefix. At present the
prefixes are:
"to:", "from:", "rtrn:", "subj:", "rcvd:", "head:", and "mime:"
and the other relevant code is:
#define MAXTOKENLEN 30
#define MAX_PREFIX_LEN 5 /* maximim length of prefix */
#define MSG_COUNT_PADDING 2 * 10 /* space for 2 10-digit numbers */
byte yylval_text[MAXTOKENLEN + MAX_PREFIX_LEN + MSG_COUNT_PADDING + D];
static word_t yylval = { 0, yylval_text };
The limit for yylval is sizeof(yylval_text) which computes to 55.
When we get serious about unicode and iconv, we'll need to make some
changes. At present, each character of a message takes 1 byte of
storage, so the single MAXTOKENLEN value is sufficient. With unicode
we'll need different counts for characters and storage, for example
MAXTOKENCHARS and MAXTOKENBYTES.
_______________________________________________
Bogofilter-dev mailing list
Bogofilter-dev at bogofilter.org
http://www.bogofilter.org/mailman/listinfo/bogofilter-dev
More information about the bogofilter-dev
mailing list