INN commit: branches/2.5 (4 files)
INN Commit
rra at isc.org
Fri Jan 22 22:25:50 UTC 2010
Date: Friday, January 22, 2010 @ 14:25:50
Author: iulius
Revision: 8912
HDR and OVER commands now return the right 423 code (instead of 420)
when the current article number is used but the article no longer exists.
Modified:
branches/2.5/include/inn/nntp.h
branches/2.5/include/nntp.h
branches/2.5/innd/nc.c
branches/2.5/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-21 21:43:43 UTC (rev 8911)
+++ include/inn/nntp.h 2010-01-22 22:25:50 UTC (rev 8912)
@@ -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-21 21:43:43 UTC (rev 8911)
+++ include/nntp.h 2010-01-22 22:25:50 UTC (rev 8912)
@@ -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-21 21:43:43 UTC (rev 8911)
+++ innd/nc.c 2010-01-22 22:25:50 UTC (rev 8912)
@@ -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-21 21:43:43 UTC (rev 8911)
+++ nnrpd/article.c 2010-01-22 22:25:50 UTC (rev 8912)
@@ -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", 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", 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