🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #6141

mthreads crash in comp.sys.laptops

#6141
From: Wayne Davison
Date: Sun, 03 Oct 1993 17:59
63 lines
2808 bytes
There's a bug in mthreads that has probably been around since version 1.0
when it parses more than 1024 bytes of references.  There's an article that
recently arrived in comp.sys.laptops that triggers this bug because there is
no space between the header and the article body and the entire article is
indented by whitespace (which is the indication of a continuation line).

The following patch can be directly applied to mthreads 3.x.  It can also
be hand-applied with only minor tweaks to any mthreads 2.x.  I've extended
the continuation-line checking in the references code to hopefully ignore
more of these bogus continuation headers in the future.

This patch will soon show up in an official release of mthreads (I wish I
had found this article before releasing version 3.1 the other day).

Index:mt-process.c
@@ -195,8 +195,8 @@
 	    } else
 	    if (len == 10 && strEQ(cp, "references")) {
+		int ref_len;
 		/* include preceding space in saved reference */
-		len = strlen(str + 1);
-		bcopy(str + 1, references, len + 1);
-		str = references + len;
+		ref_len = strlen(str + 1);
+		bcopy(str + 1, references, ref_len + 1);
 		/* check for continuation lines */
 #ifdef USE_NNTP
@@ -205,5 +205,5 @@
 		while ((cp = fgets(buf, sizeof buf, fp_article)) != Nullch) {
 #endif
-		    if (*cp != ' ' && *cp != '\t') {
+		    if ((*cp != ' ' && *cp != '\t') || !index(cp, '<')) {
 			goto process_line;
 		    }
@@ -212,13 +212,20 @@
 		    }
 		    *--cp = ' ';
+#ifdef USE_NNTP
+		    len = strlen(cp);
+#else
+		    len = strlen(cp) - 1;
+		    cp[len] = '\0';	/* remove newline */
+#endif
+		    str = references + ref_len;
 		    /* If the references are too long, shift them over to
 		    ** always save the most recent ones.
 		    */
-		    if ((len += strlen(cp)) > 1023) {
-			strcpy(buf, buf + len - 1023);
-			str -= len - 1023;
-			len = 1023;
+		    if ((ref_len += len) > 1023) {
+			strcpy(references, references + ref_len - 1023);
+			str -= ref_len - 1023;
+			ref_len = 1023;
 		    }
-		    strcpy(str, cp);
+		    bcopy(cp, str, len + 1);
 		}/* while */
 		break;
-- 
Wayne Davison
davison@borland.com
Technical Details
Message-ID: <CEC1z3.9Do@borland.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!decwrl!borland.com!davison

Show Full Headers
Complete Article Headers
Message-ID: <CEC1z3.9Do@borland.com>
Subject: mthreads crash in comp.sys.laptops
Date: Sun, 3 Oct 1993 17:59:27 GMT
From: davison@borland.com (Wayne Davison)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!decwrl!borland.com!davison
Newsgroups: news.software.readers,news.software.b
Organization: Borland International
Lines: 63