INN commit: trunk/nnrpd (commands.c line.c nnrpd.c nnrpd.h sasl.c)

INN Commit Russ_Allbery at isc.org
Sun Aug 31 10:44:38 UTC 2008


    Date: Sunday, August 31, 2008 @ 03:44:38
  Author: iulius
Revision: 7990

Fix the count of the length of the buffer.
Commands whose length was 513 octets were accepted.
We now check how many characters are stripped (especially CR which
was not in the count).

Modified:
  trunk/nnrpd/commands.c
  trunk/nnrpd/line.c
  trunk/nnrpd/nnrpd.c
  trunk/nnrpd/nnrpd.h
  trunk/nnrpd/sasl.c

------------+
 commands.c |    2 +-
 line.c     |   13 +++++++++----
 nnrpd.c    |    6 ++++--
 nnrpd.h    |    2 +-
 sasl.c     |    2 +-
 5 files changed, 16 insertions(+), 9 deletions(-)

Modified: commands.c
===================================================================
--- commands.c	2008-08-31 10:21:17 UTC (rev 7989)
+++ commands.c	2008-08-31 10:44:38 UTC (rev 7990)
@@ -534,7 +534,7 @@
 	size_t len;
 	const char *line;
 
-	r = line_read(&NNTPline, PERMaccessconf->clienttimeout, &line, &len);
+	r = line_read(&NNTPline, PERMaccessconf->clienttimeout, &line, &len, NULL);
 	switch (r) {
 	default:
 	    warn("%s internal %d in post", Client.host, r);

Modified: line.c
===================================================================
--- line.c	2008-08-31 10:21:17 UTC (rev 7989)
+++ line.c	2008-08-31 10:44:38 UTC (rev 7990)
@@ -131,7 +131,8 @@
 }
 
 READTYPE
-line_read(struct line *line, int timeout, const char **p, size_t *len)
+line_read(struct line *line, int timeout, const char **p, size_t *len,
+          size_t *stripped)
 {
     char *where;
     char *lf = NULL;
@@ -258,13 +259,17 @@
     line->remaining = where - line->where;
 
     if (r == RTok) {
-	/* if we see a full CRLF pair strip them both off before
-	 * returning the line to our caller, if we just get an LF
-	 * we'll accept that too */
+	/* If we see a full CRLF pair, strip them both off before
+	 * returning the line to our caller.  If we just get an LF
+	 * we'll accept that too (debugging INN can then be less annoying). */
 	if (lf > line->start && lf[-1] == '\r') {
 	    --lf;
+            if (stripped != NULL)
+                (*stripped)++;
 	}
 	*lf = '\0';
+        if (stripped != NULL)
+            (*stripped)++;
 	*len = lf - line->start;
 	*p = line->start;
     }

Modified: nnrpd.c
===================================================================
--- nnrpd.c	2008-08-31 10:21:17 UTC (rev 7989)
+++ nnrpd.c	2008-08-31 10:44:38 UTC (rev 7990)
@@ -1094,9 +1094,10 @@
 	}
 	else {
 	    size_t len;
+            size_t lenstripped = 0;
 	    const char *p;
 
-	    r = line_read(&NNTPline, timeout, &p, &len);
+	    r = line_read(&NNTPline, timeout, &p, &len, &lenstripped);
 	    switch (r) {
 	    default:
 		syslog(L_ERROR, "%s internal %d in main", Client.host, r);
@@ -1109,7 +1110,8 @@
 		ExitWithStats(1, false);
 		break;
 	    case RTok:
-		if (len < sizeof(buff)) {
+                /* len does not count CRLF. */
+		if (len + lenstripped <= sizeof(buff)) {
 		    /* line_read guarantees null termination */
 		    memcpy(buff, p, len + 1);
 		    /* Do some input processing, check for blank line. */

Modified: nnrpd.h
===================================================================
--- nnrpd.h	2008-08-31 10:21:17 UTC (rev 7989)
+++ nnrpd.h	2008-08-31 10:44:38 UTC (rev 7990)
@@ -287,7 +287,7 @@
 
 void line_free(struct line *);
 void line_init(struct line *);
-READTYPE line_read(struct line *, int, const char **, size_t *);
+READTYPE line_read(struct line *, int, const char **, size_t *, size_t *);
 
 #ifdef HAVE_SASL
 #include <sasl/sasl.h>

Modified: sasl.c
===================================================================
--- sasl.c	2008-08-31 10:21:17 UTC (rev 7989)
+++ sasl.c	2008-08-31 10:44:38 UTC (rev 7990)
@@ -84,7 +84,7 @@
 
 	/* get response from the client */
 	r = line_read(&NNTPline, PERMaccessconf->clienttimeout,
-		      &clientin, &clientinlen);
+		      &clientin, &clientinlen, NULL);
 	switch (r) {
 	case RTok:
 	    if (clientinlen <= BASE64_BUF_SIZE) break;



More information about the inn-committers mailing list