diff --git a/doc/pod/news.pod b/doc/pod/news.pod index dd2787618..2da930054 100644 --- a/doc/pod/news.pod +++ b/doc/pod/news.pod @@ -77,6 +77,13 @@ preserves the leading initial dot at injection time). =item * +B now rejects articles with invalid dot-stuffing (that is to say when +a dot at the beginning of a line is not doubled) as it is a violation of the +NNTP protocol. (B still goes on accepting and propagating such articles +as they have already been injected and propagated.) + +=item * + Fixed the computation of the Bytes header field by B (in header-only mode with the B<-B> flag). diff --git a/nnrpd/commands.c b/nnrpd/commands.c index e4d6f4f94..2a863d2a2 100644 --- a/nnrpd/commands.c +++ b/nnrpd/commands.c @@ -620,7 +620,7 @@ CMDpost(int ac, char *av[]) static int size; char *p, *q; char *end; - int longline; + int longline, missingdotstuffing; READTYPE r; int i; long l; @@ -748,6 +748,7 @@ CMDpost(int ac, char *av[]) end = &article[size]; longline = 0; + missingdotstuffing = 0; for (l = 1;; l++) { size_t len; const char *line; @@ -797,10 +798,12 @@ CMDpost(int ac, char *av[]) p = i + article; } - /* Reverse any byte-stuffing. */ + /* Reverse any dot-stuffing. */ if (*line == '.') { ++line; --len; + if (*line != '.' && missingdotstuffing == 0) + missingdotstuffing = l; } memcpy(p, line, len); p += len; @@ -808,7 +811,7 @@ CMDpost(int ac, char *av[]) *p = '\0'; } - if (longline) { + if (longline > 0) { warn("%s too long in post", Client.host); Reply("%d Line %d too long\r\n", ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_POST_REJECT, @@ -817,6 +820,14 @@ CMDpost(int ac, char *av[]) return; } + if (missingdotstuffing > 0) { + Reply("%d Line %d without its initial dot doubled (dot-stuffing)\r\n", + ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_POST_REJECT, + missingdotstuffing); + POSTrejected++; + return; + } + /* Send the article to the server. */ response = ARTpost(article, idbuff, &permanent); if (response == NULL) {