can't get article via NNTP, can get it via sm...

Katsuhiro Kondou Katsuhiro_Kondou at isc.org
Sun May 26 15:05:47 UTC 2002


In article <20020522.074016.23006940.kondou at isc.org>,
	Katsuhiro Kondou <Katsuhiro_Kondou at isc.org> wrote;

} } so the fix seems to be to only check up to the end of the header on
} } line 432;
} 
} I'll try to fix.  Thanks.

I wrote the patch which is successfully compiled.
The patch also fixes other problem which was reported
last October.  Could you try it, and let me know if
it's ok?
-- 
Katsuhiro Kondou

Index: include/libinn.h
===================================================================
RCS file: /home/kondou/news/inn/repository/inn/include/libinn.h,v
retrieving revision 1.115
diff -u -r1.115 libinn.h
--- include/libinn.h	23 May 2002 12:30:19 -0000	1.115
+++ include/libinn.h	26 May 2002 12:30:31 -0000
@@ -136,6 +136,8 @@
 extern char *           GenerateMessageID(char *domain);
 extern const char *     HeaderFindMem(const char *Article, int ArtLen,
                                       const char *Header, int HeaderLen); 
+extern const char *     FindEndOfHeader(const char *Body,
+                                      const char *EndOfData);
 extern const char *     HeaderFindDisk(const char *file, const char *Header,
                                        int HeaderLen);
 extern void             HeaderCleanFrom(char *from);
Index: lib/findheader.c
===================================================================
RCS file: /home/kondou/news/inn/repository/inn/lib/findheader.c,v
retrieving revision 1.13
diff -u -r1.13 findheader.c
--- lib/findheader.c	5 Oct 2000 00:32:03 -0000	1.13
+++ lib/findheader.c	26 May 2002 12:30:53 -0000
@@ -61,3 +61,25 @@
 	    return NULL;
     }
 }
+
+/* 
+ * Find end of current header
+ * just consider '\n', not '\r\n' for the non-wireformatted case
+ * if found but it's equal to EndOfData, return NULL, since it's impossible
+ * to see the next data
+ */
+const char
+*FindEndOfHeader(const char *Body, const char *EndOfData)
+{
+  char *p, *q;
+
+  for (p = (char *)Body ; p < EndOfData ; p = ++q) {
+    if ((q = memchr(p, '\n', EndOfData - p)) == NULL) {
+      return NULL;
+    }
+    if ((q < EndOfData) && (!ISWHITE(*(q + 1)))) {
+      return(q);
+    }
+  }
+  return NULL;
+}
Index: nnrpd/article.c
===================================================================
RCS file: /home/kondou/news/inn/repository/inn/nnrpd/article.c,v
retrieving revision 1.115
diff -u -r1.115 article.c
--- nnrpd/article.c	24 May 2002 15:46:55 -0000	1.115
+++ nnrpd/article.c	26 May 2002 12:34:43 -0000
@@ -363,7 +363,7 @@
 static void ARTsendmmap(SENDTYPE what)
 {
     char		*p, *q, *r, *virtualpath;
-    const char		*s, *path, *xref;
+    const char		*s, *path, *xref, *endofpath;
     long		bytecount;
     char		lastchar;
 
@@ -376,7 +376,7 @@
     if (what == STarticle) {
 	q = ARThandle->data;
 	p = ARThandle->data + ARThandle->len;
-     } else {
+    } else {
 	for (q = p = ARThandle->data; p < (ARThandle->data + ARThandle->len); p++) {
 	    if (*p == '\r')
 		continue;
@@ -411,6 +411,13 @@
 	    ARTget++;
 	    return;
 	}
+	if ((endofpath = FindEndOfHeader(path, ARThandle->data + ARThandle->len)) == NULL) {
+	    SendIOv(".\r\n", 3);
+	    ARTgetsize += 3;
+	    PushIOv();
+	    ARTget++;
+	    return;
+	}
 	if ((r = memchr(xref, ' ', q - xref)) == NULL) {
 	    SendIOv(".\r\n", 3);
 	    ARTgetsize += 3;
@@ -427,24 +434,28 @@
 		return;
 	    }
 	}
-	virtualpath = NEW(char, VirtualPathlen + 2);
-	sprintf(virtualpath, "!%s", VirtualPath);
-	for (s = path ; s + VirtualPathlen + 1 < ARThandle->data + ARThandle->len ; s++) {
-	    if (*s != *virtualpath || !EQn(s, virtualpath, VirtualPathlen + 1))
+	for (s = path, lastchar = '\0';
+	    s + VirtualPathlen + 1 < endofpath;
+	    lastchar = *s++) {
+	    if ((lastchar != '\0' && lastchar != '!') || *s != *VirtualPath ||
+		!EQn(s, VirtualPath, VirtualPathlen - 1))
+		continue;
+	    if (*(s + VirtualPathlen - 1) != '\0' &&
+		*(s + VirtualPathlen - 1) != '!')
 		continue;
 	    break;
 	}
 	if (s + VirtualPathlen + 1 < ARThandle->data + ARThandle->len) {
 	    if (xref > path) {
 	        SendIOv(q, path - q);
-	        SendIOv(s + 1, xref - (s + 1));
+	        SendIOv(s, xref - s);
 	        SendIOv(VirtualPath, VirtualPathlen - 1);
 	        SendIOv(r, p - r);
 	    } else {
 	        SendIOv(q, xref - q);
 	        SendIOv(VirtualPath, VirtualPathlen - 1);
 	        SendIOv(xref, path - xref);
-	        SendIOv(s + VirtualPathlen, p - (s + VirtualPathlen));
+	        SendIOv(s, p - s);
 	    }
 	} else {
 	    if (xref > path) {
@@ -461,7 +472,6 @@
 	        SendIOv(path, p - path);
 	    }
 	}
-	DISPOSE(virtualpath);
     } else
 	SendIOv(q, p - q);
     ARTgetsize += p - q;
@@ -489,7 +499,7 @@
 char *GetHeader(const char *header, bool IsLines)
 {
     static char		buff[40];
-    char		*p, *q, *r, *s, *t, *virtualpath;
+    char		*p, *q, *r, *s, *t, prevchar;
     /* Bogus value here to make sure that it isn't initialized to \n */
     char		lastchar = ' ';
     char		*limit;
@@ -547,21 +557,26 @@
 		    }
 		}
 		if (pathheader && (VirtualPathlen > 0)) {
-		    virtualpath = NEW(char, VirtualPathlen + 1);
-		    sprintf(virtualpath, "!%s", VirtualPath);
-		    for (s = p ; s + VirtualPathlen + 1 < ARThandle->data + ARThandle->len ; s++) {
-			if (*s != *virtualpath || !EQn(s, virtualpath, VirtualPathlen + 1))
+		    for (s = p, prevchar = '\0';
+			s + VirtualPathlen + 1 < ARThandle->data + ARThandle->len;
+			prevchar = *s++) {
+			if ((prevchar != '\0' && prevchar != '!') ||
+			    *s != *VirtualPath ||
+			    !EQn(s, VirtualPath, VirtualPathlen - 1))
+			    continue;
+			if (*(s + VirtualPathlen - 1) != '\0' &&
+			    *(s + VirtualPathlen - 1) != '!')
 			    continue;
 			break;
 		    }
 		    if (s + VirtualPathlen + 1 < ARThandle->data + ARThandle->len) {
-			memcpy(retval, s + 1, q - (s + 1));
+			memcpy(retval, s, q - s);
+			*(retval + (int)(q - s)) = '\0';
 		    } else {
 			memcpy(retval, VirtualPath, VirtualPathlen);
 			memcpy(retval + VirtualPathlen, p, q - p);
 			*(retval + (int)(q - p) + VirtualPathlen) = '\0';
 		    }
-		    DISPOSE(virtualpath);
 		} else if (xrefheader && (VirtualPathlen > 0)) {
 		    if ((r = memchr(p, ' ', q - p)) == NULL)
 			return NULL;


More information about the inn-workers mailing list