INN commit: trunk (4 files)

INN Commit rra at isc.org
Sun Jan 17 17:33:32 UTC 2010


    Date: Sunday, January 17, 2010 @ 09:33:31
  Author: iulius
Revision: 8902

Revert commit 8869 (423 is the right response code to send when
the current article number is valid but the article no longer
exists).

Besides, fix HDR and OVER to also use 423 in that case.  See
erratum 2004 on RFC 3977.

Modified:
  trunk/include/inn/nntp.h
  trunk/include/nntp.h
  trunk/innd/nc.c
  trunk/nnrpd/article.c

--------------------+
 include/inn/nntp.h |    6 +--
 include/nntp.h     |    2 -
 innd/nc.c          |    8 ++--
 nnrpd/article.c    |   89 +++++++++++++++++++++++++--------------------------
 4 files changed, 52 insertions(+), 53 deletions(-)

Modified: include/inn/nntp.h
===================================================================
--- include/inn/nntp.h	2010-01-17 13:53:28 UTC (rev 8901)
+++ include/inn/nntp.h	2010-01-17 17:33:31 UTC (rev 8902)
@@ -68,11 +68,11 @@
     NNTP_FAIL_ACTION            = 403, /* Internal fault or temporary problem */
     NNTP_FAIL_BAD_GROUP         = 411, /* Group unknown */
     NNTP_FAIL_NO_GROUP          = 412, /* Not in a newsgroup */
-    NNTP_FAIL_NO_ARTICLE        = 420, /* No current article */
+    NNTP_FAIL_ARTNUM_INVALID    = 420, /* Current article is invalid */
     NNTP_FAIL_NEXT              = 421,
     NNTP_FAIL_PREV              = 422,
-    NNTP_FAIL_BAD_ARTICLE       = 423, /* Bad article number */
-    NNTP_FAIL_NOTFOUND          = 430, /* Article not found */
+    NNTP_FAIL_ARTNUM_NOTFOUND   = 423, /* Article not found (by article number) */
+    NNTP_FAIL_MSGID_NOTFOUND    = 430, /* Article not found (by message-ID) */
     NNTP_FAIL_IHAVE_REFUSE      = 435, /* IHAVE article not wanted */
     NNTP_FAIL_IHAVE_DEFER       = 436, /* IHAVE article deferred */
     NNTP_FAIL_IHAVE_REJECT      = 437, /* IHAVE article rejected */

Modified: include/nntp.h
===================================================================
--- include/nntp.h	2010-01-17 13:53:28 UTC (rev 8901)
+++ include/nntp.h	2010-01-17 17:33:31 UTC (rev 8902)
@@ -32,8 +32,6 @@
 #define NNTP_NOTINGROUP			"412 Not in a newsgroup"
 #define NNTP_NOSUCHGROUP		"411 No such group"
 #define NNTP_NEWNEWSOK			"230 New news follows"
-#define NNTP_NOARTINGRP			"423 Bad article number"
-#define NNTP_NOCURRART			"420 No current article"
 
 /*
 **  The first character of an NNTP reply can be used as a category class.

Modified: innd/nc.c
===================================================================
--- innd/nc.c	2010-01-17 13:53:28 UTC (rev 8901)
+++ innd/nc.c	2010-01-17 17:33:31 UTC (rev 8902)
@@ -361,13 +361,13 @@
     /* Get the article token and retrieve it (to make sure
      * the article is still here). */
     if (!HISlookup(History, cp->av[1], NULL, NULL, NULL, &token)) {
-        xasprintf(&buff, "%d No such article", NNTP_FAIL_NOTFOUND);
+        xasprintf(&buff, "%d No such article", NNTP_FAIL_MSGID_NOTFOUND);
         NCwritereply(cp, buff);
         free(buff);
 	return;
     }
     if ((art = SMretrieve(token, RETR_HEAD)) == NULL) {
-        xasprintf(&buff, "%d No such article", NNTP_FAIL_NOTFOUND);
+        xasprintf(&buff, "%d No such article", NNTP_FAIL_MSGID_NOTFOUND);
         NCwritereply(cp, buff);
         free(buff);
 	return;
@@ -427,13 +427,13 @@
     /* Get the article token and retrieve it (to make sure
      * the article is still here). */
     if (!HISlookup(History, cp->av[1], NULL, NULL, NULL, &token)) {
-        xasprintf(&buff, "%d No such article", NNTP_FAIL_NOTFOUND);
+        xasprintf(&buff, "%d No such article", NNTP_FAIL_MSGID_NOTFOUND);
         NCwritereply(cp, buff);
         free(buff);
 	return;
     }
     if ((art = SMretrieve(token, RETR_STAT)) == NULL) {
-        xasprintf(&buff, "%d No such article", NNTP_FAIL_NOTFOUND);
+        xasprintf(&buff, "%d No such article", NNTP_FAIL_MSGID_NOTFOUND);
         NCwritereply(cp, buff);
         free(buff);
 	return;

Modified: nnrpd/article.c
===================================================================
--- nnrpd/article.c	2010-01-17 13:53:28 UTC (rev 8901)
+++ nnrpd/article.c	2010-01-17 17:33:31 UTC (rev 8902)
@@ -41,8 +41,6 @@
 } SENDDATA;
 
 static char		ARTnotingroup[] = NNTP_NOTINGROUP;
-static char		ARTnoartingroup[] = NNTP_NOARTINGRP;
-static char		ARTnocurrart[] = NNTP_NOCURRART;
 static ARTHANDLE        *ARThandle = NULL;
 static SENDDATA		SENDbody = {
     STbody,	NNTP_OK_BODY,		"body"
@@ -665,7 +663,7 @@
     /* Requesting by message-ID? */
     if (mid) {
 	if (!ARTopenbyid(av[1], &art, final)) {
-	    Reply("%d No such article\r\n", NNTP_FAIL_NOTFOUND);
+	    Reply("%d No such article\r\n", NNTP_FAIL_MSGID_NOTFOUND);
 	    return;
 	}
 	if (!PERMartok()) {
@@ -691,35 +689,36 @@
 
     /* Default is to get current article, or specified article. */
     if (ac == 1) {
-	if (ARTnumber < ARTlow || ARTnumber > ARThigh) {
-	    Reply("%s\r\n", ARTnocurrart);
-	    return;
-	}
-	snprintf(buff, sizeof(buff), "%lu", ARTnumber);
-	tart=ARTnumber;
-    }
-    else {
+        if (ARTnumber < ARTlow || ARTnumber > ARThigh) {
+            Reply("%d Current article number %lu is invalid\r\n",
+                  NNTP_FAIL_ARTNUM_INVALID, ARTnumber);
+            return;
+        }
+        snprintf(buff, sizeof(buff), "%lu", ARTnumber);
+        tart = ARTnumber;
+    } else {
         /* We have already checked that the article number is valid. */
-	strlcpy(buff, av[1], sizeof(buff));
-	tart=(ARTNUM)atol(buff);
+        strlcpy(buff, av[1], sizeof(buff));
+        tart = (ARTNUM)atol(buff);
     }
 
     /* Open the article and send the reply. */
-    if (!ARTopen(atol(buff))) {
-        Reply("%s\r\n", ac == 1 ? ARTnocurrart : ARTnoartingroup);
+    if (!ARTopen(tart)) {
+        Reply("%d No such article number %lu\r\n", NNTP_FAIL_ARTNUM_NOTFOUND, tart);
         return;
     }
-    if (ac > 1)
-	ARTnumber = tart;
     if ((msgid = GetHeader("Message-ID", true)) == NULL) {
         ARTclose();
-        Reply("%s\r\n", ac == 1 ? ARTnocurrart : ARTnoartingroup);
-	return;
+        Reply("%d No such article number %lu\r\n", NNTP_FAIL_ARTNUM_NOTFOUND, tart);
+        return;
     }
+    if (ac > 1)
+        ARTnumber = tart;
+
     /* A message-ID does not have more than 250 octets. */
     Reply("%d %s %.250s %s\r\n", what->ReplyCode, buff, msgid, what->Item); 
     if (what->Type != STstat)
-	ARTsendmmap(what->Type);
+        ARTsendmmap(what->Type);
     ARTclose();
 }
 
@@ -748,8 +747,9 @@
 	return;
     }
     if (ARTnumber < ARTlow || ARTnumber > ARThigh) {
-	Reply("%s\r\n", ARTnocurrart);
-	return;
+        Reply("%d Current article number %lu is invalid\r\n",
+              NNTP_FAIL_ARTNUM_INVALID, ARTnumber);
+        return;
     }
 
     /* NEXT? */
@@ -815,13 +815,14 @@
     *DidReply = false;
 
     if (ac == 1) {
-	/* No arguments, do only current article. */
-	if (ARTnumber < ARTlow || ARTnumber > ARThigh) {
-	    Reply("%s\r\n", ARTnocurrart);
-	    *DidReply = true;
-	    return false;
-	}
-	rp->High = rp->Low = ARTnumber;
+        /* No arguments, do only current article. */
+        if (ARTnumber < ARTlow || ARTnumber > ARThigh) {
+            Reply("%d Current article number %lu is invalid\r\n",
+                  NNTP_FAIL_ARTNUM_INVALID, ARTnumber);
+            *DidReply = true;
+            return false;
+        }
+        rp->High = rp->Low = ARTnumber;
         return true;
     }
 
@@ -962,10 +963,10 @@
          * Note that XOVER answers OK. */
         if (ac > 1)
             Reply("%d No articles in %s\r\n",
-                  xover ? NNTP_OK_OVER : NNTP_FAIL_BAD_ARTICLE, av[1]);
+                  xover ? NNTP_OK_OVER : NNTP_FAIL_ARTNUM_NOTFOUND, av[1]);
         else
-            Reply("%d Current article number %lu is invalid\r\n",
-                  xover ? NNTP_OK_OVER : NNTP_FAIL_NO_ARTICLE, ARTnumber);
+            Reply("%d No such article number %lu\r\n",
+                  xover ? NNTP_OK_OVER : NNTP_FAIL_ARTNUM_NOTFOUND, ARTnumber);
         if (xover)
             Printf(".\r\n");
         return;
@@ -1075,10 +1076,10 @@
          * Note that XOVER answers OK. */
         if (ac > 1)
             Reply("%d No articles in %s\r\n",
-                  xover ? NNTP_OK_OVER : NNTP_FAIL_BAD_ARTICLE, av[1]);
+                  xover ? NNTP_OK_OVER : NNTP_FAIL_ARTNUM_NOTFOUND, av[1]);
         else
-            Reply("%d Current article number %lu is invalid\r\n",
-                  xover ? NNTP_OK_OVER : NNTP_FAIL_NO_ARTICLE, ARTnumber);
+            Reply("%d No such article number %lu\r\n",
+                  xover ? NNTP_OK_OVER : NNTP_FAIL_ARTNUM_NOTFOUND, ARTnumber);
         if (xover)
             Printf(".\r\n");
     } else {
@@ -1193,7 +1194,7 @@
 	if (mid) {
 	    p = av[2];
 	    if (!ARTopenbyid(p, &artnum, false)) {
-		Reply("%d No such article\r\n", NNTP_FAIL_NOTFOUND);
+		Reply("%d No such article\r\n", NNTP_FAIL_MSGID_NOTFOUND);
 		break;
 	    }
 
@@ -1271,10 +1272,10 @@
                 if (hdr) {
                     if (ac > 2)
                         Reply("%d No articles in %s\r\n",
-                              NNTP_FAIL_BAD_ARTICLE, av[2]);
+                              NNTP_FAIL_ARTNUM_NOTFOUND, av[2]);
                     else
-                        Reply("%d Current article number %lu is invalid\r\n",
-                              NNTP_FAIL_NO_ARTICLE, ARTnumber);
+                        Reply("%d No such article number %lu\r\n",
+                              NNTP_FAIL_ARTNUM_NOTFOUND, ARTnumber);
                 } else {
                     Reply("%d No header information for %s follows (from articles)\r\n",
                           NNTP_OK_HEAD, av[1]);
@@ -1294,10 +1295,10 @@
             if (hdr) {
                 if (ac > 2)
                     Reply("%d No articles in %s\r\n",
-                          NNTP_FAIL_BAD_ARTICLE, av[2]);
+                          NNTP_FAIL_ARTNUM_NOTFOUND, av[2]);
                 else
-                    Reply("%d Current article number %lu is invalid\r\n",
-                          NNTP_FAIL_NO_ARTICLE, ARTnumber);
+                    Reply("%d No such article number %lu\r\n",
+                          NNTP_FAIL_ARTNUM_NOTFOUND, ARTnumber);
             } else {
                 Reply("%d No header information for %s follows (from overview)\r\n",
                       NNTP_OK_HEAD, av[1]);
@@ -1351,10 +1352,10 @@
             if (hdr) {
                 if (ac > 2)
                     Reply("%d No articles in %s\r\n",
-                          NNTP_FAIL_BAD_ARTICLE, av[2]);
+                          NNTP_FAIL_ARTNUM_NOTFOUND, av[2]);
                 else
                     Reply("%d Current article number %lu is invalid\r\n",
-                          NNTP_FAIL_NO_ARTICLE, ARTnumber);
+                          NNTP_FAIL_ARTNUM_INVALID, ARTnumber);
             } else {
                 Reply("%d No header or metadata information for %s follows (from overview)\r\n",
                       NNTP_OK_HEAD, av[1]);




More information about the inn-committers mailing list