maxartsize in latest STABLE

Russ Allbery rra at stanford.edu
Tue May 18 12:03:42 UTC 2004


Patrick Schreurs <patricks at support.nl> writes:

> Looks like we have a major bug in the latest STABLE snapshot
> (20040517).

Fixed in CVS.  This time I was smart and also actually made the damn code
readable so that I could figure out what was going on.

This was fallout of having to change various variables that took the
results of comparing pointers to be a size_t rather than an int, since
otherwise people were having problems with weird conversion problems on
the AMD64 architecture.  I missed one of the places where signed
vs. unsigned comparisons bit me.

I've double-checked and this fixes the problem.

--- inn/innd/art.c       2004/05/18 09:22:45     1.212.2.6
+++ inn/innd/art.c       2004/05/18 12:03:10
@@ -766,7 +766,7 @@ ARTparse(CHANNEL *cp)
 {
   struct buffer        *bp = &cp->In;
   ARTDATA      *data = &cp->Data;
-  size_t        i, limit;
+  size_t        i, limit, fudge, size;
   int          hopcount;
   char         **hops;
   HDRCONTENT   *hc = data->HdrContent;
@@ -922,7 +922,8 @@ bodyprocessing:
                  cp->Next = ++i;
                  snprintf(cp->Error, sizeof(cp->Error),
                    "%d Article of %ld bytes exceeds local limit of %ld bytes",
-                   NNTP_REJECTIT_VAL, i - cp->Start, innconf->maxartsize);
+                   NNTP_REJECTIT_VAL, (unsigned long) i - cp->Start,
+                    innconf->maxartsize);
                } else {
                  cp->State = CSgotarticle;
                  i++;
@@ -981,13 +982,11 @@ endofline:
     }
   }
 sizecheck:
-  if ((innconf->maxartsize > 0) &&
-    (i - cp->Start - (data->HeaderLines + data->Lines + 4) >
-    (unsigned long) innconf->maxartsize)) {
-    /* data->HeaderLines + data->Lines + 4 means that "\r\n" is counted as 1
-       byte and trailing ".\r\n" and body delimitor is excluded */
-    cp->State = CSeatarticle;
-  }
+  size = i - cp->Start;
+  fudge = data->HeaderLines + data->Lines + 4;
+  if (innconf->maxartsize > 0)
+    if (size > fudge && size - fudge > (size_t) innconf->maxartsize)
+        cp->State = CSeatarticle;
   cp->Next = i;
   return;
 }

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.


More information about the inn-workers mailing list