count single \r or \n as \r\n while checking line length against MAXHEADERSIZE

Julien ÉLIE julien at trigofacile.com
Mon Oct 25 18:08:46 UTC 2010


Hi Florian,

>> That's not exact:
>> * "p - q" is not the length of a line;
>
>> +    for (q = p; (p = strchr(p, '\n')) != NULL; p++) {
>> +        /* Note that '\r\n' has temporarily been internally replaced by '\n'.
>> +         * Therefore, the count takes it into account. */
>> +        if (p - q + 2 > MAXARTLINELENGTH) {
>
> I'm not too familiar with nnrpd; but on first sight, if \r\n is replaced
> by a single \n as you write, shouldn't that be +1 instead of +2?

When p is at the first char of a string and q at the last char,
then the length of the string is (p-q+1).
See for instance the case p=q for a string whose length is 1.

Besides, we add again 1 because of the missing '\r'.  Thus +2.

-- 
Julien ÉLIE

« La mathématique est une science dangereuse :
  elle dévoile les supercheries et les erreurs de calcul. » (Galilée)




More information about the inn-workers mailing list