INN commit: trunk/innd (art.c innd.h)

INN Commit Russ_Allbery at isc.org
Thu Sep 4 18:56:23 UTC 2008


    Date: Thursday, September 4, 2008 @ 11:56:22
  Author: iulius
Revision: 8001

Better count of the :bytes metadata:
* CRLF counts for 2 octets;
* the separating empty line counts.

Dot-stuffing is still counted, though it should not.

Modified:
  trunk/innd/art.c
  trunk/innd/innd.h

--------+
 art.c  |   17 +++++++++++------
 innd.h |    2 +-
 2 files changed, 12 insertions(+), 7 deletions(-)

Modified: art.c
===================================================================
--- art.c	2008-09-04 17:06:51 UTC (rev 8000)
+++ art.c	2008-09-04 18:56:22 UTC (rev 8001)
@@ -530,13 +530,13 @@
 	return result;
     }
   }
-  /* in case Xref is not included in orignal article */
+  /* In case Xref: is not included in original article. */
   if (!HDR_FOUND(HDR__XREF)) {
-    /* write heading data */
+    /* Write heading data. */
     iov[iovcnt].iov_base = (char *) p;
     iov[iovcnt++].iov_len = Article->data + (data->Body - 2) - p;
     arth.len += Article->data + (data->Body - 2) - p;
-    /* Xref needs to be inserted */
+    /* Xref: needs to be inserted. */
     iov[iovcnt].iov_base = (char *) "Xref: ";
     iov[iovcnt++].iov_len = sizeof("Xref: ") - 1;
     arth.len += sizeof("Xref: ") - 1;
@@ -588,9 +588,14 @@
     }
     data->BytesValue += iov[i].iov_len;
   }
-  /* "\r\n" is counted as 1 byte.  trailing ".\r\n" and body delimitor are also
-     substituted */
-  data->BytesValue -= (data->HeaderLines + data->Lines + 4);
+  /* Subtract the trailing 3 octets ".\r\n".  Note that we count
+   * a CRLF pair as two octets.  We also count the empty line
+   * between headers and body.
+   * FIXME:  We should also remove for each dot-stuffed lines.
+   * It is how the count of Bytes: should be done according to
+   * RFC 3977.  However, should we parse the whole body here
+   * only for that? */
+  data->BytesValue -= 3;
   /* Figure out how much space we'll need and get it. */
   snprintf(data->Bytes, sizeof(data->Bytes), "Bytes: %ld\r\n",
            data->BytesValue);

Modified: innd.h
===================================================================
--- innd.h	2008-09-04 17:06:51 UTC (rev 8000)
+++ innd.h	2008-09-04 18:56:22 UTC (rev 8001)
@@ -218,7 +218,7 @@
   int		  Lines;		/* number of body lines */
   int		  HeaderLines;		/* number of header lines */
   long		  BytesValue;		/* size of stored article, "\r\n" is
-					   counted as 1 byte */
+					   counted as 2 bytes */
   char		  Bytes[16];		/* generated Bytes header */
   int		  BytesLength;		/* generated Bytes header length */
   char	      *   BytesHeader;		/* where Bytes header begins in



More information about the inn-committers mailing list