INN commit: trunk/nnrpd (commands.c newnews.c nnrpd.c)
INN Commit
Russ_Allbery at isc.org
Tue Sep 2 18:45:21 UTC 2008
Date: Tuesday, September 2, 2008 @ 11:45:20
Author: iulius
Revision: 7998
Correctly parse the last argument of NEWGROUPS and NEWNEWS so as to
only allow GMT.
Modified:
trunk/nnrpd/commands.c
trunk/nnrpd/newnews.c
trunk/nnrpd/nnrpd.c
------------+
commands.c | 28 +++++++++++++++++++++-------
newnews.c | 41 +++++++++++++++++++++++++----------------
nnrpd.c | 4 ++--
3 files changed, 48 insertions(+), 25 deletions(-)
Modified: commands.c
===================================================================
--- commands.c 2008-09-01 20:28:19 UTC (rev 7997)
+++ commands.c 2008-09-02 18:45:20 UTC (rev 7998)
@@ -331,10 +331,18 @@
int numgroups = 0;
int numfound = 0;
int i;
- bool local;
+ bool local = true;
/* Parse the date. */
- local = !(ac > 3 && strcasecmp(av[3], "GMT") == 0);
+
+ if (ac > 3) {
+ if (strcasecmp(av[3], "GMT") == 0)
+ local = false;
+ else {
+ Reply("%d Syntax error for \"GMT\"\r\n", NNTP_ERR_SYNTAX);
+ return;
+ }
+ }
date = parsedate_nntp(av[1], av[2], local);
if (date == (time_t) -1) {
Reply("%d Bad date\r\n", NNTP_ERR_SYNTAX);
@@ -347,8 +355,8 @@
an error was causing needless confusion. Just return the empty list
of groups. */
if ((qp = QIOopen(ACTIVETIMES)) == NULL) {
- syslog(L_ERROR, "%s cant fopen %s %m", Client.host, ACTIVETIMES);
- Reply("%d New newsgroups follow.\r\n", NNTP_OK_NEWGROUPS);
+ syslog(L_ERROR, "%s can't fopen %s %m", Client.host, ACTIVETIMES);
+ Reply("%d No new newsgroups\r\n", NNTP_OK_NEWGROUPS);
Printf(".\r\n");
return;
}
@@ -390,19 +398,25 @@
QIOclose(qp);
if ((qp = QIOopen(ACTIVE)) == NULL) {
- syslog(L_ERROR, "%s cant fopen %s %m", Client.host, ACTIVE);
- Reply("%d Cannot open active file.\r\n", NNTP_ERR_UNAVAILABLE);
+ syslog(L_ERROR, "%s can't fopen %s %m", Client.host, ACTIVE);
+ Reply("%d Cannot open active file\r\n", NNTP_ERR_UNAVAILABLE);
return;
}
qsort(grouplist, numgroups, sizeof(GROUPDATA), GroupCompare);
- Reply("%d New newsgroups follow.\r\n", NNTP_OK_NEWGROUPS);
+ Reply("%d New newsgroups follow\r\n", NNTP_OK_NEWGROUPS);
for (numfound = numgroups; (p = QIOread(qp)) && numfound;) {
+ /* p will contain the name of the newsgroup.
+ * When the syntax of the line is not correct, we continue
+ * with the following line. */
if ((q = strchr(p, ' ')) == NULL)
continue;
*q++ = '\0';
+ /* Find out the end of the high water mark. */
if ((q = strchr(q, ' ')) == NULL)
continue;
q++;
+ /* Find out the end of the low water mark.
+ * q will contain the flag of the newsgroup. */
if ((q = strchr(q, ' ')) == NULL)
continue;
q++;
Modified: newnews.c
===================================================================
--- newnews.c 2008-09-01 20:28:19 UTC (rev 7997)
+++ newnews.c 2008-09-02 18:45:20 UTC (rev 7998)
@@ -1,6 +1,6 @@
/* $Revision$
**
-** The newnews command.
+** The NEWNEWS command.
*/
#include "config.h"
#include "clibrary.h"
@@ -47,7 +47,7 @@
}
/*
-** get Xref header
+** Get Xref: header.
*/
static char *
GetXref(ARTHANDLE *art)
@@ -162,7 +162,8 @@
if (innconf->nfsreader) {
time(&now);
- /* move the start time back nfsreaderdelay seconds */
+ /* Move the start time back nfsreaderdelay seconds
+ * as we are an NFS reader. */
if (date >= innconf->nfsreaderdelay)
date -= innconf->nfsreaderdelay;
}
@@ -183,7 +184,7 @@
!ARTinstorebytoken(token))
continue;
/* We only care about the newsgroup list here, virtual
- * hosting isn't relevant */
+ * hosting isn't relevant. */
p = overview_getheader(vector, overhdr_xref, OVextra);
}
if (p == NULL)
@@ -211,8 +212,8 @@
}
/*
-** NEWNEWS wildmat date time ["GMT"]
-** Return the Message-ID of any articles after the specified date
+** NEWNEWS wildmat date time [GMT]
+** Return the Message-ID of any articles after the specified date.
*/
void
CMDnewnews(int ac, char *av[])
@@ -224,7 +225,7 @@
time_t date;
QIOSTATE *qp;
int i;
- bool local;
+ bool local = true;
if (!PERMaccessconf->allownewnews) {
Reply("%d NEWNEWS command disabled by administrator\r\n", NNTP_ERR_ACCESS);
@@ -232,24 +233,33 @@
}
if (!PERMcanread) {
- Reply("%s\r\n", NNTP_ACCESS);
+ Reply("%d Read access denied\r\n", NNTP_ERR_ACCESS);
return;
}
- /* Make other processes happier if someone uses NEWNEWS */
+ /* Make other processes happier if someone uses NEWNEWS. */
if (innconf->nicenewnews > 0) {
nice(innconf->nicenewnews);
innconf->nicenewnews = 0;
}
+ if (ac > 4) {
+ if (strcasecmp(av[4], "GMT") == 0)
+ local = false;
+ else {
+ Reply("%d Syntax error for \"GMT\"\r\n", NNTP_ERR_SYNTAX);
+ return;
+ }
+ }
+
snprintf(line, sizeof(line), "%s %s %s %s", av[1], av[2], av[3],
- (ac >= 5 && (*av[4] == 'G' || *av[4] == 'U')) ? "GMT" : "local");
+ local ? "local" : "GMT");
notice("%s newnews %s", Client.host, line);
TMRstart(TMR_NEWNEWS);
- /* Optimization in case client asks for !* (no groups) */
+ /* Optimization in case client asks for !* (no groups). */
if (strcmp(av[1], "!*") == 0) {
- Reply("%s\r\n", NNTP_NEWNEWSOK);
+ Reply("%d No new news\r\n", NNTP_OK_NEWNEWS);
Printf(".\r\n");
TMRstop(TMR_NEWNEWS);
return;
@@ -264,7 +274,6 @@
}
/* Parse the date. */
- local = !(ac > 4 && strcasecmp(av[4], "GMT") == 0);
date = parsedate_nntp(av[2], av[3], local);
if (date == (time_t) -1) {
Reply("%d Bad date\r\n", NNTP_ERR_SYNTAX);
@@ -273,8 +282,8 @@
}
if (strcspn(av[1], "\\!*[?]") == strlen(av[1])) {
- /* optimise case - don't need to scan the active file pattern
- * matching */
+ /* Optimise case -- don't need to scan the active file pattern
+ * matching. */
Reply("%s\r\n", NNTP_NEWNEWSOK);
for (i = 0; groups[i]; ++i) {
process_newnews(groups[i], AllGroups, date);
@@ -286,7 +295,7 @@
if (errno == ENOENT) {
Reply("%d Can't open active\r\n", NNTP_ERR_UNAVAILABLE);
} else {
- syswarn("%s cant fopen %s", Client.host, path);
+ syswarn("%s can't fopen %s", Client.host, path);
Reply("%d Can't open active\r\n", NNTP_ERR_UNAVAILABLE);
}
free(path);
Modified: nnrpd.c
===================================================================
--- nnrpd.c 2008-09-01 20:28:19 UTC (rev 7997)
+++ nnrpd.c 2008-09-02 18:45:20 UTC (rev 7998)
@@ -133,9 +133,9 @@
{ "MODE", CMDmode, false, 2, 2,
"READER" },
{ "NEWGROUPS", CMDnewgroups, true, 3, 4,
- "[yy]yymmdd hhmmss [\"GMT\"]" },
+ "[yy]yymmdd hhmmss [GMT]" },
{ "NEWNEWS", CMDnewnews, true, 4, 5,
- "wildmat [yy]yymmdd hhmmss [\"GMT\"]" },
+ "wildmat [yy]yymmdd hhmmss [GMT]" },
{ "NEXT", CMDnextlast, true, 1, 1,
NULL },
{ "POST", CMDpost, true, 1, 1,
More information about the inn-committers
mailing list