INN commit: trunk/storage (ov.c)

INN Commit rra at isc.org
Tue Dec 29 22:35:13 UTC 2009


    Date: Tuesday, December 29, 2009 @ 14:35:13
  Author: iulius
Revision: 8874

When adding an overview line with OVadd(), check that Xref: is
at the beginning of an overview field (that is to say that a
tabulation precedes it).

Otherwise, if for instance one has User-Agent:full in LIST
OVERVIEW.FMT and an article is received with the following
header field:
User-Agent: test Xref: server test:50
then the overview data for article 50 in newsgroup test is
replaced by the one of this article.  And the real article
number of this article is unknown for the overview.

Modified:
  trunk/storage/ov.c

------+
 ov.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Modified: ov.c
===================================================================
--- ov.c	2009-12-29 22:21:20 UTC (rev 8873)
+++ ov.c	2009-12-29 22:35:13 UTC (rev 8874)
@@ -131,20 +131,21 @@
     ARTNUM		artnum;
 
     if (!ov.open) {
-	/* must be opened */
+	/* Must be opened. */
         warn("ovopen must be called first");
 	return OVADDFAILED;
     }
 
     /*
-     * find last Xref: in the overview line.  Note we need to find the *last*
+     * Find last Xref: in the overview line.  Note we need to find the *last*
      * Xref:, since there have been corrupted articles on Usenet with Xref:
      * fragments stuck in other header lines.  The last Xref: is guaranteed
      * to be from our server.
      */
 
     for (next = data; ((len - (next - data)) > 6 ) && ((next = memchr(next, 'X', len - (next - data))) != NULL); ) {
-        if (memcmp(next, "Xref: ", 6) == 0) {
+        /* Check that Xref: is at the beginning of an overview field. */
+        if (memcmp(next, "Xref: ", 6) == 0 && next != data && next[-1] == '\t') {
             found =  true;
             xrefstart = next;
         }
@@ -163,8 +164,8 @@
     xreflen = len - (next - data);
 
     /*
-     * If there are other fields beyond Xref in overview, then
-     * we must find Xref's end, or data following is misinterpreted.
+     * If there are other fields beyond Xref: in overview, then
+     * we must find Xref:'s end, or data following is misinterpreted.
      */
     if ((xrefend = memchr(next, '\t', xreflen)) != NULL)
 	xreflen = xrefend - next;
@@ -201,9 +202,9 @@
             *nextcheck++ = '\0';
             if (!OVgroupmatch(group)) {
                 if (!SMprobe(SELFEXPIRE, &token, NULL) && innconf->groupbaseexpiry)
-                    /* this article will never be expired, since it does not
+                    /* This article will never be expired, since it does not
                        have self expiry function in stored method and
-                       groupbaseexpiry is true */
+                       groupbaseexpiry is true. */
                     return OVADDFAILED;
                 return OVADDGROUPNOMATCH;
             }
@@ -212,7 +213,7 @@
     memcpy(xrefdata, next, xreflen);
     xrefdata[xreflen] = '\0';
     for (group = xrefdata; group && *group; group = memchr(next, ' ', xreflen - (next - xrefdata))) {
-        /* Parse the xref part into group name and article number */
+        /* Parse the Xref: part into group name and article number. */
         while (isspace((int)*group))
             group++;
         if ((next = memchr(group, ':', xreflen - (group - xrefdata))) == NULL)




More information about the inn-committers mailing list