🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
28 messages
28 total messages Started by Jan-Pieter Cornet Thu, 06 Mar 1997 00:00
innd 1.5.1 dumps core. buffer overflow?
#15572
Author: Jan-Pieter Cornet
Date: Thu, 06 Mar 1997 00:00
52 lines
3081 bytes
I'm seeing very frequent (like once or twice a day) innd 1.5.1 coredumps,
it looks like a buffer overflow to me. Here's some information from
gdb on the latest core:

newsfeed:/news/spool # gdb /usr/local/etc/innd innd.core
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.15.1 (i386-unknown-bsdi2.1), 
Copyright 1995 Free Software Foundation, Inc...
Core was generated by `innd'.
Program terminated with signal 11, Segmentation fault.
#0  0x14ffd in NGfind (Name=0x11480f "sci.skeptic") at ng.c:276
276             if (c == ngp[0]->Name[0] && EQ(Name, ngp[0]->Name))
(gdb) bt   
#0  0x14ffd in NGfind (Name=0x11480f "sci.skeptic") at ng.c:276
#1  0x4fde in ARTpost (cp=0x53b70, Replic=0x0, 
    ihave=0x4951c00 "<01bc2975$a6b4a3e0$e7d992cf@default>") at art.c:1962
#2  0xf4c9 in NCpostit (cp=0x53b70) at nc.c:235
#3  0x11a44 in NCproc (cp=0x53b70) at nc.c:1086
#4  0x12310 in NCreader (cp=0x53b70) at nc.c:1311
#5  0xb52f in CHANreadloop () at chan.c:873
#6  0xe915 in main (ac=0, av=0xefbfdef4) at innd.c:952
(gdb) p ngp
$1 = (NEWSGROUP **) 0x578840
(gdb) p ngp[0]
$2 = (NEWSGROUP *) 0x74656e2e
(gdb) p ngp[0]->Name   
Cannot access memory at address 0x74656e32.
(gdb) p (char*) ngp
$3 = 0x578840 ".net>\nfj/mail/5362 <5fk0hi$9b5@news.nc.u-tokyo.ac.jp>\nrec/arts/comics/marketplace/159026 <5fjisd$1h1@taurus.adnc.com>\ncontrol/4104995 <cancel.5fi4vf$mkp@news1-alterdial.uu.net>\nalt/sports/football/pro"...

My hope is that someone already found this and says "oh install patch ...",
but if not I'm willing to dive into it a bit more... though i'm not that
familiar with the innd code, there are probably others that know it better
than i do.

BTW, for anyone who reads this post all the way here, I've made a patch
to nnrpd that mmap()s the .overview files, and binary searches them,
which resulted in a tremendous speedup especially if you have lots
of readers reading big groups. You need a superior mmap implementation
for that, though (I also have a script that tests your mmap :). Volunteers
to test it, or should I just post the patch here?

--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`

Re: INND 1.5.1 crashing
#15577
Author: Jan-Pieter Cornet
Date: Thu, 06 Mar 1997 00:00
31 lines
1757 bytes
In article <331EE55D.1493@cwix.net>,
Damian J. Anderson <damian@cwix.net> wrote:
>I am having a problem with a news server running INND 1.5.1 crashing
>following an attempted flush. The syslog entry just prior to the crash
>is:
>
>Mar  6 09:05:06 tipu2.cwix.net innd: malta:41:proc:4977 cant flush count
>871986
>
>Anyone have any ideas?

It might be related to the same bug I'm seeing (see my earlier message
with subject "innd 1.5.1 dumps core. buffer overflow?", or follow back
the proper reference), because now that you mention it, I often saw
a "cant flush" message in the logs shortly before to the server died.

Have you tried doing a post-mortem on the core(ps) of innd?

Regards,

--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`

(PS: sorry about the crosspost. I couldn't resist. Anyone looking for
a binary in this: try to uudecode my .sig! :)

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15583
Author: Chris Bellomy
Date: Thu, 06 Mar 1997 00:00
25 lines
1634 bytes
Jan-Pieter Cornet (johnpc@xs4all.nl) wrote:
: Below is a patch to mmap() .overview files, and binary search them.
: This greatly speeds up the XOVER command (and other commands that
: use the .overview database), especially when you have really large
: groups.

I tried this on a high-traffic leaf node server running Solaris
2.5.1 (and therefore with a good mmap()).  I setup the patched
nnrpd to be called by inetd on port 120, and did some informal
testing myself.  The unpatched version (on 119) consistently
out-performed the patched one (on 120), sometimes dramatically.
Is there something I'm missing here?

FWIW, my system is a Sun Ultra E-4000 w/4 CPU's, one gig of RAM,
and an average of about 450 readers (at peak, >700; at off-hours,
<300).  Active, history and overview each reside on separate disks,
and (of course) overview is not in the article spool.

-- 
Chris Bellomy				Flashnet Communications
Senior System Administrator		Fort Worth, Texas
cbellomy@flash.net			(817)332-8878

patch for nnrpd 1.5.1 to mmap .overview files
#15600
Author: Jan-Pieter Cornet
Date: Thu, 06 Mar 1997 00:00
843 lines
24160 bytes
Below is a patch to mmap() .overview files, and binary search them.
This greatly speeds up the XOVER command (and other commands that
use the .overview database), especially when you have really large
groups.

I wrote this especially because the disk holding the overview database
was so overloaded it caused enourmous delays. Using mmap and a binary
search greatly reduces the amount of data read from disk, because
.overview files are now shared between processes, and because people
usually only want the last part of the .overview files anyway.

This consists of two parts: first the unified diff for nnrpd/article.c,
adding the mmap()ed .overview files. If you remove the #define OVERSCREAM,
then you get the old behaviour back.

The second part is a script to test your mmap() implementation, it's a
shar consisting of a C program and a bash script. You'll have to compile
the C program yourself (usually "make mmapme" will do just fine), and then
run the script. The test script hexdumps three files. All files should
only contain "1" (hex 31) characters. If you also see hex 00 characters,
then your mmap is flawed, and you need to bug your vendor for a patch.
(If the test script says "mmap: invalid parameters" or some similar error,
try running "mmap-test -p").

The patch has code to work around the mmap() bug, but it's kludgy, slow,
and not always returns the correct results.

--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`


----8<----------------------------------------------------------------

--- article.c	1997/02/08 14:19:13	1.1
+++ article.c	1997/03/06 17:29:27
@@ -1,4 +1,4 @@
-/*  $Revision: 1.1 $
+/*  $Revision: 1.31 $
 **
 **  Article-related routines.
 */
@@ -8,6 +8,18 @@
 #include "clibrary.h"
 #include "nnrpd.h"
 
+/*
+ * OVERSCREAM - to make the overview database screaming fast, and because
+ * I scream in terror about the previous implementation.
+ */
+
+#define OVERSCREAM
+
+#ifdef OVERSCREAM
+# include <sys/types.h>
+# include <sys/mman.h>
+#endif /* OVERSCREAM */
+
 
 /*
 **  Data structures for use in ARTICLE/HEAD/BODY/STAT common code.
@@ -61,11 +73,32 @@
 /*
 **  Overview state information.
 */
+#ifdef OVERSCREAM
+
+STATIC caddr_t		OVERshm = (caddr_t) NULL; /* location of mmap	*/
+STATIC size_t		OVERsize;		/* size of mmap		*/
+STATIC int		OVERfd;			/* fd of file 		*/
+STATIC ARTNUM		OVERfirst, OVERlast;	/* first/last entries	*/
+STATIC int		OVERopens;		/* Number of opens done	*/
+STATIC char*		OVERcache;		/* cached position	*/
+STATIC ARTNUM		OVERprev;		/* previous found art	*/
+#define LINSEARCH	5			/* linear search range  */
+#define MIDSKEW		0.1			/* 10% bias toward middle */
+
+STATIC int		mmapsuck;		/* did we syslog already */
+#define YOUR_MMAP_SUCKS if ( ! mmapsuck++ ) \
+    syslog(L_NOTICE, "Your mmap() implementation sucks.")
+
+#else /* !OVERSCREAM */
+
 STATIC QIOSTATE		*OVERqp;		/* Open overview file	*/
 STATIC char		*OVERline;		/* Current line		*/
 STATIC ARTNUM		OVERarticle;		/* Current article	*/
 STATIC int		OVERopens;		/* Number of opens done	*/
 
+#endif
+
+
 
 /*
 **  Read the overview schema.
@@ -676,6 +709,10 @@
     register int	i;
     ARTOVERFIELD	*fp;
     char		*next;
+#ifdef OVERSCREAM
+    char*		eol = strchr(p, '\n');
+#endif
+
 
     fp = &ARTfields[field - 1];
 
@@ -683,8 +720,13 @@
       field = ARTfirstfullfield;
  
     /* Skip leading headers. */
-    for (; --field >= 0 && *p; p++)
+    for (; --field >= 0 && *p && *p != '\n'; p++)
+#ifdef OVERSCREAM
+	if ((p = memchr(p, '\t', OVERsize - (p - OVERshm))) == NULL ||
+	    p > eol )
+#else
 	if ((p = strchr(p, '\t')) == NULL)
+#endif
 	    return NULL;
     if (*p == '\0')
 	return NULL;
@@ -702,10 +744,22 @@
     }
   
     /* Figure out length; get space. */
+
+#ifdef OVERSCREAM
+    if ((next = memchr(p, '\t', OVERsize - (p - OVERshm))) != NULL &&
+	  p < eol )
+	i = next - p;
+    else 
+	i = eol - p;
+
+#else /* !OVERSCREAM */
+
     if ((next = strchr(p, '\t')) != NULL)
 	i = next - p;
     else
 	i = strlen(p);
+#endif
+
     if (buffsize == 0) {
 	buffsize = i;
 	buff = NEW(char, buffsize + 1);
@@ -720,6 +774,408 @@
     return buff;
 }
 
+#ifdef OVERSCREAM
+
+/*
+ * helper function, search backwards in memory
+ */
+
+STATIC char*
+memrchr(p, c, l)
+    register char* p;
+    register char c;
+    register int l;
+{
+    for (; l--; --p)
+	if ( *p == c )
+	    return(p);
+    return(NULL);
+}
+
+/*
+ * mmap an OVERVIEW file.
+ */
+
+STATIC BOOL
+OVERopen()
+{
+    char		name[SPOOLNAMEBUFF];
+    struct stat 	sb;
+    char*		p;
+    static int		pagesize = 0;
+
+    /* return true if already mapped */
+    if ( OVERshm ) {
+	return TRUE;
+    }
+    /* return false if already failed */
+    if ( OVERopens++ ) {
+	return FALSE;
+    }
+    /* get memory pagesize if we don't have it already */
+    if ( ! pagesize && ! (pagesize = getpagesize()) ) {
+	syslog(L_NOTICE, "%s: Can't getpagesize", ClientHost);
+	return FALSE;
+    }
+    /* mmap the file */
+    (void)sprintf(name, "%s/%s/%s", _PATH_OVERVIEWDIR, GRPlast, _PATH_OVERVIEW);
+    if ( (OVERfd = open(name, O_RDONLY)) < 0 ) {
+	/* no overview file */
+	syslog(L_NOTICE, "%s can't open %s: %m", ClientHost, name);
+	return FALSE;
+    }
+    if ( fstat(OVERfd, &sb) == -1 ) {
+	syslog(L_NOTICE, "%s can't stat %s: %m", ClientHost, name);
+	(void)close(OVERfd);
+	return FALSE;
+    }
+    if ( (OVERsize = sb.st_size) <= 1 ) {
+	syslog(L_NOTICE, "%s: %s is too small", ClientHost, name);
+	(void)close(OVERfd);
+	return FALSE;
+    }
+    if ( (OVERshm = mmap(NULL, (OVERsize + pagesize - 1) & ~pagesize,
+	                 PROT_READ, 0, OVERfd, 0)) == (caddr_t) -1 )
+    {
+	syslog(L_NOTICE, "%s can't mmap %s: %m", ClientHost, name);
+	(void)close(OVERfd);
+	OVERshm = NULL;
+	return FALSE;
+    }
+    /* get first entry */
+    if ( (OVERfirst = atol((char*) OVERshm)) == 0 ) {
+	syslog(L_NOTICE, "%s: %s: bad format", ClientHost, name);
+	(void)munmap(OVERshm, OVERsize);
+	(void)close(OVERfd);
+	OVERshm = NULL;
+	return FALSE;
+    }
+
+    /* get last entry */
+    if ( *(OVERshm + OVERsize - 1) != '\n' ) {
+	/*
+	 * If you get here, then your mmap() implementation sucks.
+	 * Go complain with your OS vendor, that their mmap() can't
+	 * do mmap()ing of growing files properly.
+	 * We try to find a decent record near the end, for the poor
+	 * sobs without proper mmap. There are a lot of other places
+	 * in the code with hacks for bad mmap(). Mainly because I'm
+	 * one of the poor sobs :(
+	 */
+	YOUR_MMAP_SUCKS;
+    }
+    do {
+	p = memrchr(OVERshm + OVERsize - 1, '\n', OVERsize - 1);
+	if ( p == NULL ) {
+	    (void)munmap(OVERshm, OVERsize);
+	    (void)close(OVERfd);
+	    OVERshm = NULL;
+	    return FALSE;
+	}
+	OVERsize = p - OVERshm + 1;
+	if ( (p = memrchr((char*) OVERshm + OVERsize - 2, '\n',
+			    OVERsize - 1)) == NULL )
+	{
+	    syslog(L_NOTICE, "%s: %s: bad format", ClientHost, name);
+	    (void)munmap(OVERshm, OVERsize);
+	    (void)close(OVERfd);
+	    OVERshm = NULL;
+	    return FALSE;
+	}
+	OVERlast = atol(p+1);
+    }
+    while ( OVERlast == 0 && OVERsize-- );
+
+    OVERcache = NULL;
+    return TRUE;
+}
+
+/*
+ * Close an overview file, if any.
+ */
+
+void
+OVERclose()
+{
+    if ( OVERshm ) {
+	if ( munmap(OVERshm, OVERsize) == -1 ) {
+	    syslog(L_NOTICE, "%s can't munmap: %m", ClientHost);
+	}
+	(void)close(OVERfd);
+	OVERshm = NULL;
+    }
+    OVERopens = 0;
+}
+
+/*
+ * find an overview article using binary search in the overview file.
+ * Returns a pointer to the actual line in the overview file (so it's
+ * !!NOT!! null terminated, and can't be written to!!), or NULL on failure.
+ */
+
+STATIC char*
+OVERfind(artnum)
+    ARTNUM	artnum;
+{
+    char*	bottom;
+    char*	top;
+    ARTNUM	bottomnr;
+    ARTNUM	topnr;
+    char*	pos;
+    ARTNUM	nr;
+    int		i;
+
+    /* default startpos */
+    bottom = OVERshm;
+    bottomnr = OVERfirst;
+    top = OVERshm + OVERsize - 1;
+    topnr = OVERlast;
+
+    if ( OVERcache ) {
+	/*
+	 * for speedy sequential access. OVERcache, if non-NULL, points to
+	 * the "next" entry. OVERprev is the previous article number found.
+	 * Also check for sucking mmap() implementations.
+	 */
+	if ( *OVERcache == '\0' ) {
+	    YOUR_MMAP_SUCKS;
+	    OVERcache = memchr(OVERcache, '\n',
+				OVERsize - (OVERshm - OVERcache));
+	    if ( OVERcache == NULL || OVERcache == OVERshm + OVERsize - 1 ) {
+		OVERcache = NULL;
+		return NULL;
+	    }
+	    OVERcache++;
+	}
+	nr = atol(OVERcache);
+	if ( nr < OVERfirst || nr > OVERlast ) {
+	    /* boo */
+	    OVERcache = NULL;
+	    return NULL;
+	}
+	if ( nr == artnum ) {
+	    pos = OVERcache;
+	    goto bingo; /* calculate next OVERcache + return. (EW! a goto! :) */
+	}
+	else if ( artnum > nr ) {
+	    /* treat cache as first binary search */
+	    bottom = OVERcache;
+	    bottomnr = nr;
+	}
+	else {
+	    /* cache is first top */
+	    top = OVERcache - 1;
+	    topnr = nr - 1;
+	    if ( artnum > OVERprev ) {
+		/*
+		 * optimization: we're searching for something that isn't
+		 * in the database, but we want to keep the cache clean.
+		 * this occurs when we think an article is there, but it
+		 * really isn't, eg. because NOSCANDIR is on, or simply
+		 * because the overview database leaks.
+		 */
+		return(NULL);
+	    }
+	}
+    }
+
+    /* sanity check */
+    if ( artnum < bottomnr || artnum > topnr ) {
+	OVERcache = NULL;
+	return NULL;
+    }
+
+    for (;;) {
+	/*
+	 * This is the binary search loop, there are about a zillion
+	 * exits so I found it neater to code it in an endless loop :)
+	 * It simply continues until it is either found or it isn't...
+	 *
+	 * Note that we don't do a real binary search, but we guess
+	 * a position using the fact that the overview database usually
+	 * contains a reasonably linear range of articles, without any
+	 * big leaps, but we skew it a bit towards the middle to prevent
+	 * slow convergence in boundary cases (see also below).
+	 *
+	 * We switch to linear searching when we're "close",
+	 * because on short ranges, linear searches are about as fast
+	 * (or faster) anyway. LINSEARCH is currently guessed at 5,
+	 * because on average it takes 2.5 searches using a linear search,
+	 * where it usually takes 3 "straight" binary searches.
+	 *
+	 * Unfortunately, we can't be sure we get into linear search when
+	 * we're close, because the database may have large holes.
+	 */
+	/* test if it's near the bottom */
+	if ( artnum < bottomnr + LINSEARCH ) {
+	    i = 0;
+	    while ( artnum > bottomnr && i++ < LINSEARCH ) {
+		/* search next line */
+		bottom = memchr(bottom, '\n', OVERsize - (bottom - OVERshm));
+		if ( bottom == NULL || bottom == top + 1 ) {
+		    /* reached end of file */
+		    OVERcache = NULL;
+		    return NULL;
+		}
+		if ( *++bottom == 0 ) {
+		    YOUR_MMAP_SUCKS;
+		    continue;
+		}
+		bottomnr = atol(bottom);
+		if ( bottomnr < OVERfirst || bottomnr > OVERlast ) {
+		    OVERcache = NULL;
+		    return NULL;
+		}
+	    }
+	    if ( artnum == bottomnr ) {
+		pos = bottom;
+		goto bingo; /* calculate next OVERcache + return. */
+	    }
+	    else {
+		/* didn't find it, but we came close. still cache position */
+		OVERcache = bottom;
+		OVERprev = artnum;
+		return NULL;
+	    }
+	    /*NOTREACHED*/
+	}
+	/* test if it's near the top */
+	if ( artnum > topnr - LINSEARCH ) {
+	    /*
+	     * topnr is frequently guessed, so we must first determine it
+	     * correctly. The fun part about searching backwards is that
+	     * the next position (OVERcache) follows easily...
+	     */
+	    i = 0;
+	    do {
+		OVERcache = (top == OVERshm + OVERsize - 1) ? NULL : top + 1;
+		if ( (top = memrchr(--top, '\n', top - OVERshm))
+		    == NULL || top + 1 == bottom )
+		{
+		    /* search hit bottom */
+		    OVERcache = NULL;
+		    return NULL;
+		}
+		if ( *(top + 1) == 0 ) {
+		    YOUR_MMAP_SUCKS;
+		    /* make sure we continue */
+		    topnr = artnum + 1;
+		    continue;
+		}
+		topnr = atol(top + 1);
+		if ( topnr < OVERfirst || topnr > OVERlast ) {
+		    OVERcache = NULL;
+		    return NULL;
+		}
+	    }
+	    while ( artnum < topnr && i++ < LINSEARCH );
+	    if ( artnum == topnr ) {
+		/* bingo. This time we know OVERcache already */
+		OVERprev = artnum;
+		return(top + 1);
+	    }
+	    else {
+		/* not found, but close. cache position */
+		OVERprev = artnum;
+		return NULL;
+	    }
+	    /*NOTREACHED*/
+	}
+
+	/*
+	 * now for the real binary search:
+	 * Estimate the position of artnum, but with a small offset towards
+	 * the middle, for better convergence in case the set of articles
+	 * is non-linear (you get a straight binary search if MIDSKEW is 1.0).
+	 * MIDSKEW is currently determined using a big thumb, occultism,
+	 * astrology, cat /dev/uri-geller and some common sense (but not much)
+	 * MIDSKEW == 0.0 makes the search take only 1 iteration in case
+	 * the overview database is a monotonous array of lines with equal
+	 * length, but can make for really lousy searches in anything not like
+	 * the above, which, in the real world, is practically always.
+	 * MIDSKEW == 1.0 gives you a true binary search without any guessing
+	 * whatsoever.
+	 * I thought 10% would be good enough. Only riggid testing can
+	 * determine the optimal value, and then it still depends on a lot
+	 * of settings, like expire times, user newsgroups preference,
+	 * presence of cancelbots or cancelwars, frequency of expireover
+	 * runs... need I say more? :)
+	 */
+	if ( topnr <= bottomnr ) {
+	    /* Safety net. This REALLY should never happen. */
+	    syslog(L_NOTICE,
+		   "%s: ASSERTION FAILED: %d < %d looking for %d in %s",
+		   ClientHost, topnr, bottomnr, artnum, GRPlast);
+	}
+	pos = bottom + (int) ((double) (top - bottom) * (MIDSKEW * 0.5) +
+			      (top - bottom) * (1.0 - MIDSKEW) *
+			      (artnum - bottomnr) / (topnr - bottomnr));
+	/* search forward for newline */
+	if ( (pos = memchr(pos, '\n', OVERsize - (pos - OVERshm))) == NULL ) {
+	    /* this shouldn't happen */
+	    OVERcache = NULL;
+	    return NULL;
+	}
+	if ( pos == top ) {
+	    /* hmm... */
+	    if ( (pos = memrchr(--pos, '\n', pos - OVERshm))
+		 == NULL || pos == bottom - 1 )
+	    {
+		/*
+		 * This is what happens when there's a large hole and we're
+		 * looking for something inside the hole (which isn't there).
+		 * still record the position in this case...
+		 */
+		OVERcache = (top == OVERshm + OVERsize - 1) ? NULL : top + 1;
+		OVERprev = artnum;
+		return NULL;
+	    }
+	}
+	/* see where we are */
+	if ( *++pos == 0 ) {
+	    YOUR_MMAP_SUCKS;
+	    pos = memchr(pos, '\n', OVERsize - (pos - OVERshm));
+	    if ( pos == NULL || pos == OVERshm + OVERsize - 1 || pos == top ) {
+		OVERcache = NULL;
+		return NULL;
+	    }
+	    pos++;
+	}
+	nr = atol(pos);
+	if ( nr < OVERfirst || nr > OVERlast ) {
+	    OVERcache = NULL;
+	    return NULL;
+	}
+	if ( nr == artnum ) {
+	    /* bingo. Set cache to next entry */
+bingo:
+	    OVERcache = memchr(pos, '\n', OVERsize - (pos - OVERshm));
+	    if ( OVERcache == OVERshm + OVERsize - 1 )
+		OVERcache = NULL;
+	    else if ( OVERcache )
+		OVERcache++;
+	    OVERprev = artnum;
+	    return (pos);
+	}
+	if ( nr < artnum ) {
+	    /* found a new bottom */
+	    bottom = pos;
+	    bottomnr = nr;
+	}
+	else /* nr > artnum */ {
+	    /*
+	     * found a new top. Setting topnr to nr-1 is not entirely
+	     * correct, but who cares. (In fact we do care, but adjust
+	     * later :)
+	     */
+	    top = pos - 1;
+	    topnr = nr - 1;
+	}
+    }
+    /*NOTREACHED*/
+}
+
+#else /* !OVERSCREAM */
 
 /*
 **  Open an OVERVIEW file.
@@ -756,7 +1212,7 @@
     if (OVERqp != NULL) {
 	QIOclose(OVERqp);
 	OVERqp = NULL;
-	OVERopens = 0;
+	OVERopens = 0; /* this is a bug */
     }
 }
 
@@ -789,6 +1245,8 @@
     return OVERarticle == artnum ? OVERline : NULL;
 }
 
+#endif
+
 
 /*
 **  Read an article and create an overview line without the trailing
@@ -1078,12 +1536,22 @@
 	if (ARTfind(i) < 0)
 	    continue;
 
+	/*OVERVIEWcount++;*/
 	if (Opened && (p = OVERfind(i)) != NULL) {
+#ifdef OVERSCREAM
+	    char* eol = memchr(p, '\n', OVERsize - (p - OVERshm));
+	    if ( eol == NULL )
+		continue; /* this should NEVER NEVER EVER NEVER EVER happen */
+	    fwrite(p, 1, eol - p, stdout);
+	    fwrite("\r\n", 1, 2, stdout);
+#else
 	    Printf("%s\r\n", p);
+#endif
 	    continue;
 	}
 
 	(void)sprintf(buff, "%ld", i);
+	/*OVERGENcount++;*/
 	if ((p = OVERgen(buff)) != NULL)
 	    Printf("%s\r\n", p);
     }

----8<----------------------------------------------------------------


#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1997-02-17 19:09 MET by <john@pc.xs4all.nl>.
# Source directory was `/home/john/c'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   2073 -rw-r--r-- mmapme.c
#    360 -rwxr-xr-x mmap-test
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh06781; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= mmapme.c ==============
if test -f 'mmapme.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'mmapme.c' '(file already exists)'
else
  $echo 'x -' extracting 'mmapme.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'mmapme.c' &&
#include <unistd.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
X
#define USAGE "\
Usage:\n\
\n\
mmapme [-p] filename\n"
X
extern int optind;
X
int main(int argc, char** argv) {
X    int fd;
X    char* p;
X    char* shm;
X    struct stat st;
X    int size, pagesize;
X    char line[80];
X    char prevline[80];
X    char* c;
X    int i, j, sup, previ;
X    int adjust = 0;
X
X    while ( (i = getopt(argc, argv, "p")) != EOF ) {
X	if ( i == 'p' ) {
X	    adjust++;
X	}
X	else {
X	    fprintf(stderr, USAGE);
X	    exit(1);
X	}
X    }
X    if ( optind != argc - 1 ) {
X	fprintf(stderr, USAGE);
X	exit(1);
X    }
X    if ( (fd = open(argv[optind], O_RDONLY)) == -1 ) {
X	perror("open");
X	exit(1);
X    }
X    if ( fstat(fd, &st) ) {
X	perror("stat");
X	exit(1);
X    }
X    size = st.st_size;
X    if ( adjust ) {
#ifdef _SC_PAGE_SIZE
X	pagesize = sysconf(_SC_PAGE_SIZE);
#else
# ifdef _SC_PAGESIZE
X	pagesize = sysconf(_SC_PAGESIZE);
# else
X	pagesize = getpagesize();
# endif
#endif
X	size = (size + pagesize - 1) & ~pagesize;
X    }
X    if ( (shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0))
X          == (void*) -1 ) {
X	perror("mmap");
X	exit(1);
X    }
X    prevline[0] = '\0';
X    sup = 0;
X    p = shm;
X    for (i = 0; i < st.st_size; i += 16 ) {
X	c = line;
X	for (j = i; j < i+16 && j < st.st_size; j++) {
X	    sprintf(c, "%02X ", *p++);
X	    c += 3;
X	}
X	if ( !strcmp(prevline, line) ) {
X	    previ = i;
X	    sup++;
X	    continue;
X	}
X	if ( sup == 1 ) {
X	    printf("%08X %s\n", previ, prevline);
X	    sup = 0;
X	}
X	else if ( sup == 2 ) {
X	    printf("%08X %s\n%08X %s\n", previ - 16, prevline, previ, prevline);
X	    sup = 0;
X	}
X	else if ( sup > 2 ) {
X	    printf("... %d lines ...\n%08X %s\n", sup - 1, previ, prevline);
X	    sup = 0;
X	}
X	printf("%08X %s\n", i, line);
X	strcpy(prevline, line);
X	previ = i;
X    }
X    if ( sup == 1 ) {
X	printf("%08X %s\n", previ, prevline);
X    }
X    else if ( sup > 1 ) {
X	printf("... %d lines ...\n%08X %s\n", sup - 1, previ, prevline);
X    }
X    sleep(60);
X    munmap(shm, size);
X    close(fd);
X    return(0);
}
SHAR_EOF
  $shar_touch -am 0217163997 'mmapme.c' &&
  chmod 0644 'mmapme.c' ||
  $echo 'restore of' 'mmapme.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'mmapme.c:' 'MD5 check failed'
aa506ce6ec404c9619828b709ccf214f  mmapme.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'mmapme.c'`"
    test 2073 -eq "$shar_count" ||
    $echo 'mmapme.c:' 'original size' '2073,' 'current size' "$shar_count!"
  fi
fi
# ============= mmap-test ==============
if test -f 'mmap-test' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'mmap-test' '(file already exists)'
else
  $echo 'x -' extracting 'mmap-test' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'mmap-test' &&
#!/bin/bash
X
echo -n 1111111111111111111111111111111111111111 > 40
cat 40 40 40 40 40 40 > 240
cat 240 240 240 240 40 > 1k
cat 1k 1k 1k 1k 1k > 5k
rm 40 240
cp 5k testfile
echo 1
X./mmapme $* testfile &
sleep 5
echo 1.5
cat 1k >> testfile
echo 2
X./mmapme $* testfile &
sleep 5
echo 2.5
cat 5k >> testfile
echo 3
X./mmapme $* testfile &
sleep 2
rm 1k 5k testfile
SHAR_EOF
  $shar_touch -am 0217120797 'mmap-test' &&
  chmod 0755 'mmap-test' ||
  $echo 'restore of' 'mmap-test' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'mmap-test:' 'MD5 check failed'
204a9c56650abab19f4f9d1e5012f401  mmap-test
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'mmap-test'`"
    test 360 -eq "$shar_count" ||
    $echo 'mmap-test:' 'original size' '360,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh06781
exit 0

Re: innd 1.5.1 dumps core. buffer overflow?
#15614
Author: Clayton O'Neill
Date: Fri, 07 Mar 1997 00:00
15 lines
1333 bytes
On 6 Mar 1997 14:16:15 GMT, Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:
>BTW, for anyone who reads this post all the way here, I've made a patch
>to nnrpd that mmap()s the .overview files, and binary searches them,
>which resulted in a tremendous speedup especially if you have lots
>of readers reading big groups. You need a superior mmap implementation
>for that, though (I also have a script that tests your mmap :). Volunteers
>to test it, or should I just post the patch here?

Could you please post it here?  I've recently done work on mmaping and
indexing overview files to eliminate searching them and would be interested
in comparing implementations.  We've seen a huge (8-10x) performance
increase on loading overviews from the indexing alone.

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15628
Author: Jeff Garzik
Date: Fri, 07 Mar 1997 00:00
39 lines
2128 bytes
Chris Bellomy wrote:
> Jan-Pieter Cornet (johnpc@xs4all.nl) wrote:
> : Below is a patch to mmap() .overview files, and binary search them.

> I tried this on a high-traffic leaf node server running Solaris
> 2.5.1 (and therefore with a good mmap()).  I setup the patched
> nnrpd to be called by inetd on port 120, and did some informal
> testing myself.  The unpatched version (on 119) consistently
> out-performed the patched one (on 120), sometimes dramatically.
> Is there something I'm missing here?


It seems to me that you are not quantitatively comparing the two.  In
order for this patch to be of benefit, multiple users need to be MMAPing
the same large .overview file(s).

You said you were on a high-traffic leaf server.  Installed the MMAP
patch for a couple of days, and record memory consumption, disk I/O, and
load avg every 5 minutes.  Then replace the unpatched version and record
system stats again.  Post the results and impress everyone here :)


Also, if MMAP is a win only on large .overview files, would it make
sense to change the patch so that an intelligent decision is made to
MMAP or not based on .overview size?  If you don't want to stat the
.overview each time, you could just check the active file entry and
guess based on the number of articles.

	Jeff



-- 
Galbraith's Law of Human Nature:
	Faced with the choice between changing one's mind and proving that
	there is no need to do so, almost everybody gets busy on the proof.

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15688
Author: Andrew A. Vasilyev
Date: Sun, 09 Mar 1997 00:00
21 lines
1347 bytes
In news.software.nntp Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:
JC>Below is a patch to mmap() .overview files, and binary search them.
JC>This greatly speeds up the XOVER command (and other commands that
JC>use the .overview database), especially when you have really large
JC>groups.


  There are at least 2 problems with this patch under Solaris (and
  I'm afraid not only under this OS):

  1. 4-th argument of mmap() ('flags') should be MAP_SHARED, not 0
     as in given source, because mmap() failed with EINVAL (there is
     no flag == 0).

  2. We mmap() a region with the size of (f_size + pagesize - 1) & ~pagesize,
     but munmap() only file_size. Not so good.
________
	ANDY

Re: innd 1.5.1 dumps core. buffer overflow?
#15685
Author: James Youngman
Date: Mon, 10 Mar 1997 00:00
41 lines
2280 bytes
In article <5fmjjf$qcg$1@news1.xs4all.nl>, johnpc@xs4all.nl says...
>
>I'm seeing very frequent (like once or twice a day) innd 1.5.1 coredumps,
>it looks like a buffer overflow to me. Here's some information from
>gdb on the latest core:

[ snip ]

I keep getting crashes from innd 1.5.1 (whereas 1.4unoff3 never did this);

[root@halon news]# gdb /usr/sbin/innd
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (i586-unknown-linux), Copyright 1996 Free Software Foundation, Inc...
(no debugging symbols found)...
(gdb) core core
Core was generated by `/usr/sbin/innd -p8 -i0 -L'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libc.so.5.3.12...(no debugging symbols found)...done.
Reading symbols from /lib/ld-linux.so.1...(no debugging symbols found)...done.
#0  0x40041840 in __libc_realloc ()
(gdb) info shared
From        To          Syms Read   Shared Object Library
0x40008000  0x400d206c  Yes         /lib/libc.so.5.3.12
0x40000000  0x400059bc  Yes         /lib/ld-linux.so.1                 

I realise this is not teribly useful, since there are no symbols, but OTOH 
since it is a problem with free(), it's probably caused by a pointer error 
elsewhere in the program anyway, in which case the current call stack is of 
dubious usefulness.


-- 
James Youngman       VG Gas Analysis Systems  The trouble with the rat-race 
Before sending advertising material, read     is, even if you win, you're 
http://www.law.cornell.edu/uscode/47/227.html         still a rat.


Re: patch for nnrpd 1.5.1 to mmap .overview files
#15689
Author: Clayton O'Neill
Date: Mon, 10 Mar 1997 00:00
15 lines
1416 bytes
On 9 Mar 1997 19:08:57 GMT, Andrew A. Vasilyev <andy@snm.demos.su> wrote:
>  2. We mmap() a region with the size of (f_size + pagesize - 1) & ~pagesize,
>     but munmap() only file_size. Not so good.

Am I missing something?  Why would we even bother to try to page align the
end?  I don't know of any OS's that require that, and I know that Linux and
Solaris don't.  BTW, I've also written code to mmap the overview, but my
code also has changes to overchan and expireover to generate flat indexes of
of the overviews in a separate file.  This way there is no linear search of
the overview files, just the (simple) indexes.  If anyone is interested I
can generate a diff, but unfortunately it's against 1.4unoff4 since we
haven't upgraded yet.

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15691
Author: Clayton O'Neill
Date: Mon, 10 Mar 1997 00:00
22 lines
1914 bytes
On Mon, 10 Mar 1997 14:04:19 -0500, Evan Champion <evanc@synapse.net> wrote:
>Clayton O'Neill wrote:
>> Am I missing something?  Why would we even bother to try to page align the
>> end?  I don't know of any OS's that require that, and I know that Linux and
>> Solaris don't.  BTW, I've also written code to mmap the overview, but my
>> code also has changes to overchan and expireover to generate flat indexes of
>> of the overviews in a separate file.  This way there is no linear search of
>> the overview files, just the (simple) indexes.  If anyone is interested I
>> can generate a diff, but unfortunately it's against 1.4unoff4 since we
>> haven't upgraded yet.
>
>I'd be interested in that if you could make up a diff against 1.5.1.

I'm planning on it eventually.  However, right now I'm more busy hacking up
nnrpd.  I'll probably produce a jumbo patch to 1.5.1 for article mmaping,
overview index, overview mmaping, and hashhack support for nnrpd.  I'll be
more than glad to make my 1.4unoff4 source available if anyone is interested
in doing the conversion to 1.5.1.  BTW, does anyone know where I can find
virgin 1.4unoff4 source that I can diff against?  

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15697
Author: Evan Champion
Date: Mon, 10 Mar 1997 00:00
16 lines
1389 bytes
Clayton O'Neill wrote:
> Am I missing something?  Why would we even bother to try to page align the
> end?  I don't know of any OS's that require that, and I know that Linux and
> Solaris don't.  BTW, I've also written code to mmap the overview, but my
> code also has changes to overchan and expireover to generate flat indexes of
> of the overviews in a separate file.  This way there is no linear search of
> the overview files, just the (simple) indexes.  If anyone is interested I
> can generate a diff, but unfortunately it's against 1.4unoff4 since we
> haven't upgraded yet.

I'd be interested in that if you could make up a diff against 1.5.1.

Evan

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15701
Author: bill davidsen
Date: Mon, 10 Mar 1997 00:00
18 lines
1337 bytes
In article <5fn38s$3q0$1@news1.xs4all.nl>,
Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:
| Below is a patch to mmap() .overview files, and binary search them.
| This greatly speeds up the XOVER command (and other commands that
| use the .overview database), especially when you have really large
| groups.

Someone said they had a patch to mmap and sort the .overview file,
which is useful on slave machines which tend to get the files out
of order. Unfortunately I can't seem to find the patch or the
person, which is bad because I could really use it!
--
	-bill davidsen (davidsen@tmr.com)
"As a software development model, Anarchy does not scale well."
		-Dave Welch

Re: innd 1.5.1 dumps core. buffer overflow?
#15702
Author: Matt Dillon
Date: Mon, 10 Mar 1997 00:00
58 lines
3129 bytes
:In article <5g10ej$9o9$2@halon.vggas.com>,
:James Youngman <JYoungman@vggas.com> wrote:
:>In article <5fmjjf$qcg$1@news1.xs4all.nl>, johnpc@xs4all.nl says...
:>>
:>>I'm seeing very frequent (like once or twice a day) innd 1.5.1 coredumps,
:>>it looks like a buffer overflow to me. Here's some information from
:>>gdb on the latest core:
:>
:>[ snip ]
:>
:>I keep getting crashes from innd 1.5.1 (whereas 1.4unoff3 never did this);
:>
:>[root@halon news]# gdb /usr/sbin/innd
:>GDB is free software and you are welcome to distribute copies of it
:> under certain conditions; type "show copying" to see the conditions.
:>There is absolutely no warranty for GDB; type "show warranty" for details.
:>GDB 4.16 (i586-unknown-linux), Copyright 1996 Free Software Foundation, Inc...
:>(no debugging symbols found)...
:>(gdb) core core
:>Core was generated by `/usr/sbin/innd -p8 -i0 -L'.
:>Program terminated with signal 11, Segmentation fault.
:>Reading symbols from /lib/libc.so.5.3.12...(no debugging symbols found)...done.
:>Reading symbols from /lib/ld-linux.so.1...(no debugging symbols found)...done.
:>#0  0x40041840 in __libc_realloc ()
:>(gdb) info shared
:>From        To          Syms Read   Shared Object Library
:>0x40008000  0x400d206c  Yes         /lib/libc.so.5.3.12
:>0x40000000  0x400059bc  Yes         /lib/ld-linux.so.1                 
:>
:>I realise this is not teribly useful, since there are no symbols, but OTOH 
:>since it is a problem with free(), it's probably caused by a pointer error 
:>elsewhere in the program anyway, in which case the current call stack is of 
:>dubious usefulness.
:>
:>
:>-- 
:>James Youngman       VG Gas Analysis Systems  The trouble with the rat-race 
:>Before sending advertising material, read     is, even if you win, you're 
:>http://www.law.cornell.edu/uscode/47/227.html         still a rat.

    Make sure the process isn't running out of memory.  Check the resource
    limits for the machine:  The 'limit' from csh. 

    innd takes a shitload of VM.  The datasize limit needs to be a minimum
    of 128 megabytes (131072).  You may have to adjust the rc.news
    startup script for innd to fix the resource limits before it runs innd.

    If that isn't the problem, it's more likely a memory corruption problem.
    Not so much a bug in malloc/realloc/free as a bug in innd somewhere.

    It might also be helpful if you did a stack backtrace from the
    core dump.. the 'back' command in gdb, I believe.

						-Matt


Re: patch for nnrpd 1.5.1 to mmap .overview files
#15703
Author: Andrew A. Vasilyev
Date: Mon, 10 Mar 1997 00:00
13 lines
1166 bytes
In news.software.nntp Clayton O'Neill <coneill@oneill.net> wrote:
CO>Am I missing something?  Why would we even bother to try to page align the
CO>end?  I don't know of any OS's that require that, and I know that Linux and

  It was the 3-rd question I had not asked :)) And simply mmap()
  (file_size + 1) - but probably one byte also is not necessary? :))

CO>Solaris don't.  BTW, I've also written code to mmap the overview, but my
________
	ANDY

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15704
Author: Matt Dillon
Date: Mon, 10 Mar 1997 00:00
32 lines
1887 bytes
:In article <5g0pba$dot$1@news.demos.su>,
:Andrew A. Vasilyev  <andy@snm.demos.su> wrote:
:>In news.software.nntp Clayton O'Neill <coneill@oneill.net> wrote:
:>CO>Am I missing something?  Why would we even bother to try to page align the
:>CO>end?  I don't know of any OS's that require that, and I know that Linux and
:>
:>  It was the 3-rd question I had not asked :)) And simply mmap()
:>  (file_size + 1) - but probably one byte also is not necessary? :))
:>
:>CO>Solaris don't.  BTW, I've also written code to mmap the overview, but my
:>________
:>	ANDY

    Warning warning will robinson!

    Many operating systems do not allow you to mmap() a file beyond it's
    logical end-of-file.  If the file size falls on a page boundry, and you
    try to mmap(..., size + 1, ...), many OS's will not allow it and mmap()
    will return an error.

    I believe FreeBSD and linux allow you to map beyond the EOF.  IRIX
    most definitely does *NOT*, however.  I don't know about SunOs.

    The insidiousness of the problem is that if the file's size does not
    fall on a page boundry, mmap() will often be successful, so many 
    programmers do not spot the problem immediately.

					-Matt


Re: patch for nnrpd 1.5.1 to mmap .overview files
#15732
Author: Jan-Pieter Cornet
Date: Tue, 11 Mar 1997 00:00
126 lines
4878 bytes
In article <5fv1s9$8ki$1@news.demos.su>,
Andrew A. Vasilyev  <andy@snm.demos.su> wrote:
>In news.software.nntp Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:
>JC>Below is a patch to mmap() .overview files, and binary search them.
>JC>This greatly speeds up the XOVER command (and other commands that
>JC>use the .overview database), especially when you have really large
>JC>groups.
>
>
>  There are at least 2 problems with this patch under Solaris (and
>  I'm afraid not only under this OS):
>
>  1. 4-th argument of mmap() ('flags') should be MAP_SHARED, not 0
>     as in given source, because mmap() failed with EINVAL (there is
>     no flag == 0).

"Oops". That is most probably the reason Chris Bellomy sees the huge
performance decrease with this patch... or it could be getpagesize doesn't
work on solaris 2.5.1.

It should've said MAP_SHARED there, don't know why I changed that... I
have been tinkering with the mmap() arguments because I was seeing
errors, but in the end they were caused by something else.

>  2. We mmap() a region with the size of (f_size + pagesize - 1) & ~pagesize,
>     but munmap() only file_size. Not so good.

I guess that could be classified as a bug as well.

I've patched these problems in my source. Patch included below.
Note: this is a patch against the earlier patched version! If you want
the entire patch, contact me.

--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`


--- 1.31	1997/03/06 17:29:26
+++ article.c	1997/03/11 16:42:30
@@ -1,4 +1,4 @@
-/*  $Revision: 1.31 $
+/*  $Revision: 1.32 $
 **
 **  Article-related routines.
 */
@@ -77,6 +77,7 @@
 
 STATIC caddr_t		OVERshm = (caddr_t) NULL; /* location of mmap	*/
 STATIC size_t		OVERsize;		/* size of mmap		*/
+STATIC size_t		OVERmsize;		/* real size of mmap	*/
 STATIC int		OVERfd;			/* fd of file 		*/
 STATIC ARTNUM		OVERfirst, OVERlast;	/* first/last entries	*/
 STATIC int		OVERopens;		/* Number of opens done	*/
@@ -813,7 +814,17 @@
 	return FALSE;
     }
     /* get memory pagesize if we don't have it already */
-    if ( ! pagesize && ! (pagesize = getpagesize()) ) {
+    if ( ! pagesize && !
+#ifdef _SC_PAGE_SIZE
+	(pagesize = sysconf(_SC_PAGE_SIZE))
+#else
+# ifdef _SC_PAGESIZE
+	(pagesize = sysconf(_SC_PAGESIZE))
+# else
+	(pagesize = getpagesize())
+# endif
+#endif
+	) {
 	syslog(L_NOTICE, "%s: Can't getpagesize", ClientHost);
 	return FALSE;
     }
@@ -834,8 +845,9 @@
 	(void)close(OVERfd);
 	return FALSE;
     }
-    if ( (OVERshm = mmap(NULL, (OVERsize + pagesize - 1) & ~pagesize,
-	                 PROT_READ, 0, OVERfd, 0)) == (caddr_t) -1 )
+    OVERmsize = (OVERsize + pagesize - 1) & ~pagesize;
+    if ( (OVERshm = mmap(NULL, OVERmsize, PROT_READ, MAP_SHARED, OVERfd, 0))
+	 == (caddr_t) -1 )
     {
 	syslog(L_NOTICE, "%s can't mmap %s: %m", ClientHost, name);
 	(void)close(OVERfd);
@@ -845,7 +857,7 @@
     /* get first entry */
     if ( (OVERfirst = atol((char*) OVERshm)) == 0 ) {
 	syslog(L_NOTICE, "%s: %s: bad format", ClientHost, name);
-	(void)munmap(OVERshm, OVERsize);
+	(void)munmap(OVERshm, OVERmsize);
 	(void)close(OVERfd);
 	OVERshm = NULL;
 	return FALSE;
@@ -867,7 +879,7 @@
     do {
 	p = memrchr(OVERshm + OVERsize - 1, '\n', OVERsize - 1);
 	if ( p == NULL ) {
-	    (void)munmap(OVERshm, OVERsize);
+	    (void)munmap(OVERshm, OVERmsize);
 	    (void)close(OVERfd);
 	    OVERshm = NULL;
 	    return FALSE;
@@ -877,7 +889,7 @@
 			    OVERsize - 1)) == NULL )
 	{
 	    syslog(L_NOTICE, "%s: %s: bad format", ClientHost, name);
-	    (void)munmap(OVERshm, OVERsize);
+	    (void)munmap(OVERshm, OVERmsize);
 	    (void)close(OVERfd);
 	    OVERshm = NULL;
 	    return FALSE;
@@ -898,7 +910,7 @@
 OVERclose()
 {
     if ( OVERshm ) {
-	if ( munmap(OVERshm, OVERsize) == -1 ) {
+	if ( munmap(OVERshm, OVERmsize) == -1 ) {
 	    syslog(L_NOTICE, "%s can't munmap: %m", ClientHost);
 	}
 	(void)close(OVERfd);

Re: innd 1.5.1 dumps core. buffer overflow?
#15736
Author: Alan Brown
Date: Tue, 11 Mar 1997 00:00
19 lines
1175 bytes
In article <5fmjjf$qcg$1@news1.xs4all.nl>,
Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:

>Program terminated with signal 11, Segmentation fault.


On Linux systems this is strongly indicative of a cache ram fault.

YMMV for BSD derivatives.

AB
-- 
o Stamp out unauthorised relay-hosting. This SMTP "feature" shouldn't default 
  "on" - See http://www.vix.com/spam/ and http://www.sendmail.org/antispam.html
o Junk email returned, in bulk, back to sender; w/copies to all postmasters.
o Received junkmail constitutes a request for aggressive site security probing.

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15738
Author: Andrew A. Vasilyev
Date: Tue, 11 Mar 1997 00:00
37 lines
2305 bytes
In news.software.nntp Matt Dillon <dillon@flea.best.net> wrote:
MD>    Warning warning will robinson!

  Unfortunately I do not know such TV person or what he is -
  but I believe that was a joke :)))

MD>    Many operating systems do not allow you to mmap() a file beyond it's
MD>    logical end-of-file.  If the file size falls on a page boundry, and you
MD>    try to mmap(..., size + 1, ...), many OS's will not allow it and mmap()
MD>    will return an error.
MD>    I believe FreeBSD and linux allow you to map beyond the EOF.  IRIX
MD>    most definitely does *NOT*, however.  I don't know about SunOs.

  Well, is is easy to check:

Under Solaris "
     mmap() allows [_p_a, _p_a + _l_e_n) to extend beyond the end of the
     object, both at the time of the mmap() and while the mapping
     persists, such as when the file was created just before  the
     mmap()  and  has  no  contents, or if the file is truncated.
     Any reference to addresses beyond the  end  of  the  object,
     however, will result in the delivery of a SIGBUS signal.  In
     other words, mmap() cannot be used to implicitly extend  the
     length of files.
"

  So it is safe to mmap() file_size+any_more, BUT one should not
  read beyond the EOF, AND do not forget to unmmap mapped region.

MD>    The insidiousness of the problem is that if the file's size does not
MD>    fall on a page boundry, mmap() will often be successful, so many 
MD>    programmers do not spot the problem immediately.
_______
	ANDY

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15781
Author: bill davidsen
Date: Wed, 12 Mar 1997 00:00
21 lines
1450 bytes
In article <5g1u60$q41@flea.best.net>,
Matt Dillon <dillon@flea.best.net> wrote:

|     Warning warning will robinson!
| 
|     Many operating systems do not allow you to mmap() a file beyond it's
|     logical end-of-file.  If the file size falls on a page boundry, and you
|     try to mmap(..., size + 1, ...), many OS's will not allow it and mmap()
|     will return an error.

Good thing the original code says it rounds up to the end of the
highest page used. I'm not totally sure why you need to go beyond
the size of the file, I assume that some systems require the size in
even page multiples.
--
	-bill davidsen (davidsen@tmr.com)
"As a software development model, Anarchy does not scale well."
		-Dave Welch

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15800
Author: Andrew A. Vasilyev
Date: Wed, 12 Mar 1997 00:00
22 lines
1560 bytes
In news.software.nntp Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:
JC>"Oops". That is most probably the reason Chris Bellomy sees the huge
JC>performance decrease with this patch... or it could be getpagesize doesn't
JC>work on solaris 2.5.1.

  getpagesize() works fine, but you've not answered the question: why is
  it necessary to align maped region on page boundary?

  AND there is at least one more bug: if we have a single line in .overview
  file, we get a second "bad format" error (after second memrchr() in
  do {} while() loop). Probably the author correct this problem?

JC>I've patched these problems in my source. Patch included below.
JC>Note: this is a patch against the earlier patched version! If you want
JC>the entire patch, contact me.

  It's funny but I've also named the real mmap size as 'OVERmsize' :))
_______
	ANDY

Re: innd 1.5.1 dumps core. buffer overflow?
#15845
Author: Dennis Simpson
Date: Thu, 13 Mar 1997 00:00
44 lines
2440 bytes
> >Program terminated with signal 11, Segmentation fault.

We have been seeing this ever since going to 1.5.1 on our Solaris
2.5.1 machine. 1.4unoff4 never had it. In our case, the finish of
nntpsend (cron job) causes the crash. I rebuilt -g and the stack
looks like so:

%[29] adb innd /news/inndcore.970307.10:19
core file = /news/inndcore.970307.10:19	-- program ``innd'' on platform
SUNW,SPARCsystem-600
SIGSEGV: Segmentation Fault
$c
t_splay(0x946f20,0x946f38,0x946f28,0x37383220,0xd038d8,0x2589340) + 138
t_delete(0x946f20,0xef5d5a68,0x3f12760,0x946f30,0x35948,0x946f18) + 58
realloc(?) + 118
__fnonstd_used(0x9115d8,0x35d48,0x67c78,0x2,0x150f8,0x946f20) +	137ac
xrealloc(0x9115d8,0x35d48,0xffffffff,0x0,0x6a988,0x3303c) + 4c
SITEwritefromflags(0xed6490,0xeffff208,0xffffffff,0x6d1b8,0x0,0xed64ec)
+ 31a0
SITEsend(0xed6490,0xeffff208,0xae7,0xfa52c7,0x5e104,0x9939c8) +	8c
ARTpost(0xdf1ab8,0x1feb884,0x0,0x415,0x8,0x99d678) + 2230
NCpostit(0x6a728,0xf026b8c8,0x400,0x11c0423,0x11c0464,0x11c0464) + 10c
NCproc(0x6a728,0xf026b8c8,0x994460,0x6a780,0x6a780,0x11c0466) +	d00
NCreader(0x6a728,0xcb9a20,0x2fe,0x0,0xefffdd30,0x994460) + 168
CHANreadloop(0x6a6f8,0x6a728,0x5b,0x2b,0xc,0x2fe) + 794
main(0x4,0xeffffe74,0xeffffe88,0x67400,0x1,0x0)	+ 1808

This one also looks like a malloc problem, in that it would appear
something is being re-alloc'ed that is free.

I've not yet set aside the time to debug further, but if anyone else
is dealing with a similar crash, or has solved it already, I'd like
to know.

Thx,
dennis
--
/---------------------------------------------------------------------\
| Dennis Simpson  dennis@bconnex.net http://www.bconnex.net/~dennis   |
| "A winner listens, a loser waits for their turn to talk." - unknown |
\---------------------------------------------------------------------/

Re: innd 1.5.1 dumps core. buffer overflow?
#15860
Author: Dennis Simpson
Date: Thu, 13 Mar 1997 00:00
31 lines
1773 bytes
Dennis Simpson wrote:
> 
> > >Program terminated with signal 11, Segmentation fault.
> 
> We have been seeing this ever since going to 1.5.1 on our Solaris
> 2.5.1 machine. 1.4unoff4 never had it. In our case, the finish of
> nntpsend (cron job) causes the crash. I rebuilt -g and the stack
> looks like so:
> 
> %[29] adb innd /news/inndcore.970307.10:19
> SITEwritefromflags(0xed6490,0xeffff208,0xffffffff,0x6d1b8,0x0,0xed64ec)
> + 31a0

Ok. Never mind. This is a bug in innd, in that it drops core and should
handle the problem more gracefully, but, this one was caused by having
Tc.Wnm instead of Tc,Wnm in my newsfeeds file.

Either that or the 3 field line I also corrected in hosts.nntp at
the same time. See, I was looking at the section of code that dropped,
and was overcome with the brilliance of doing an inncheck.

Thx,
dennis
--
/---------------------------------------------------------------------\
| Dennis Simpson  dennis@bconnex.net http://www.bconnex.net/~dennis   |
| "A winner listens, a loser waits for their turn to talk." - unknown |
\---------------------------------------------------------------------/

Re: innd 1.5.1 dumps core. buffer overflow?
#15876
Author: Chrisy Luke
Date: Fri, 14 Mar 1997 00:00
22 lines
1305 bytes
On 11 Mar 1997 21:30:11 +1300, alan@news.manawatu.gen.nz (Alan Brown)
wrote:

>In article <5fmjjf$qcg$1@news1.xs4all.nl>,
>Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:

>>Program terminated with signal 11, Segmentation fault.

>On Linux systems this is strongly indicative of a cache ram fault.

I've found similar messages occuring on a machine with duff memory,
with non-parity SIMMs or parity & ECC disabled.

Chris.

== chrisy@easynet.net, chrisy@flirble.org, chrisy@etsiig.uniovi.es
== Newsmaster and Senior Systems Developer for Easynet Group Plc.
== I recently saw a Flirble, in the bushes on Regents Park. It
== frowned at me and said "If it were Wimbledon you wouldn't stare!"

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15916
Author: David Power
Date: Sat, 15 Mar 1997 00:00
11 lines
925 bytes
coneill@oneill.net (Clayton O'Neill) wrote:

>can generate a diff, but unfortunately it's against 1.4unoff4 since we
>haven't upgraded yet.

Id love a copy of the diff. We are still running the 1.4unoff4 also.

dpower@insync.net

Re: patch for nnrpd 1.5.1 to mmap .overview files
#15940
Author: Jan-Pieter Cornet
Date: Mon, 17 Mar 1997 00:00
118 lines
4192 bytes
In article <5g61g0$hak$2@news.demos.su>,
Andrew A. Vasilyev  <andy@snm.demos.su> wrote:
>  getpagesize() works fine, but you've not answered the question: why is
>  it necessary to align maped region on page boundary?

I had some systems barf if I didn't align on a page boundary, I think it
was some Linux version, might be related to the libc version... and it
says in the manual page somewhere that it should be aligned on a pagesize,
so I decided to play it safe.

>  AND there is at least one more bug: if we have a single line in .overview
>  file, we get a second "bad format" error (after second memrchr() in
>  do {} while() loop). Probably the author correct this problem?

Thanks! Yes, that's another bug. Actually there were several bugs dwelling
in that part of the code, apparently I was a bit sleepy when I wrote that.
Another (incremental) patch included below. I've put the total patch on
my homepage, which contains the full patch against 1.5.1. See:
http://www.xs4all.nl/~johnpc/inn/

>  It's funny but I've also named the real mmap size as 'OVERmsize' :))

Heh :) Quite a coincidence, indeed.

[mailed and posted]

Best regards,

--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`


--- article.c	1997/03/11 16:42:28	1.32
+++ article.c	1997/03/17 09:47:31
@@ -1,4 +1,4 @@
-/*  $Revision: 1.32 $
+/*  $Revision: 1.37 $
 **
 **  Article-related routines.
 */
@@ -804,6 +804,8 @@
     struct stat 	sb;
     char*		p;
     static int		pagesize = 0;
+    int			hadlf;
+
 
     /* return true if already mapped */
     if ( OVERshm ) {
@@ -845,7 +847,7 @@
 	(void)close(OVERfd);
 	return FALSE;
     }
-    OVERmsize = (OVERsize + pagesize - 1) & ~pagesize;
+    OVERmsize = (OVERsize + pagesize - 1) & ~(pagesize - 1);
     if ( (OVERshm = mmap(NULL, OVERmsize, PROT_READ, MAP_SHARED, OVERfd, 0))
 	 == (caddr_t) -1 )
     {
@@ -864,7 +866,7 @@
     }
 
     /* get last entry */
-    if ( *(OVERshm + OVERsize - 1) != '\n' ) {
+    if ( !(hadlf = *(OVERshm + OVERsize - 1) == '\n') ) {
 	/*
 	 * If you get here, then your mmap() implementation sucks.
 	 * Go complain with your OS vendor, that their mmap() can't
@@ -877,13 +879,23 @@
 	YOUR_MMAP_SUCKS;
     }
     do {
-	p = memrchr(OVERshm + OVERsize - 1, '\n', OVERsize - 1);
+	p = memrchr(OVERshm + OVERsize - 2, '\n', OVERsize - 2);
 	if ( p == NULL ) {
-	    (void)munmap(OVERshm, OVERmsize);
-	    (void)close(OVERfd);
-	    OVERshm = NULL;
-	    return FALSE;
+	    if ( hadlf ) {
+		/* Apparently only 1 (usable) line */
+		OVERlast = OVERfirst;
+		OVERcache = NULL;
+		return TRUE;
+	    }
+	    else {
+		/* overview file only contains garbage. */
+		(void)munmap(OVERshm, OVERmsize);
+		(void)close(OVERfd);
+		OVERshm = NULL;
+		return FALSE;
+	    }
 	}
+	hadlf = TRUE;
 	OVERsize = p - OVERshm + 1;
 	if ( (p = memrchr((char*) OVERshm + OVERsize - 2, '\n',
 			    OVERsize - 1)) == NULL )
@@ -896,7 +908,14 @@
 	}
 	OVERlast = atol(p+1);
     }
-    while ( OVERlast == 0 && OVERsize-- );
+    while ( OVERlast == 0 && --OVERsize >= 2 );
+
+    if ( OVERsize < 2 ) {
+	(void)munmap(OVERshm, OVERmsize);
+	(void)close(OVERfd);
+	OVERshm = NULL;
+	return FALSE;
+    }
 
     OVERcache = NULL;
     return TRUE;

Re: innd 1.5.1 dumps core. buffer overflow?
#15956
Author: Jan-Pieter Cornet
Date: Mon, 17 Mar 1997 00:00
31 lines
2050 bytes
In article <33373e01.49947846@news.flirble.org>,
Chrisy Luke <chrisy@easynet.net> wrote:
>On 11 Mar 1997 21:30:11 +1300, alan@news.manawatu.gen.nz (Alan Brown)
>wrote:
>
>>In article <5fmjjf$qcg$1@news1.xs4all.nl>,
>>Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:
>>>Program terminated with signal 11, Segmentation fault.
>>On Linux systems this is strongly indicative of a cache ram fault.
>I've found similar messages occuring on a machine with duff memory,
>with non-parity SIMMs or parity & ECC disabled.

I've never seen a parity error cause a big chunk of memory to be
overwritten. It *can* happen, of course, it's just extremely
unlikely. Expecially if you have it happening day after day in
precisely the same way. And we're not that much closer to Chernobyl
that it actually makes a measurable difference in alpha radiation :)

This definately is an innd 1.5.1 bug. It's just picky about which
systems it occurs on, apparently. There's very strong suspicion
it's related to flushing a channel. I still haven't had time to
investigate further :( (not being that familiar with innd guts)

--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`

Re: patch for nnrpd 1.5.1 to mmap .overview files
#16062
Author: Jan-Pieter Cornet
Date: Wed, 19 Mar 1997 00:00
145 lines
5585 bytes
[mailed and posted]
OK, so it's really lame to followup on your own article, but... I issued
another nonsensical patch :(

In article <5gj4cb$ppu$1@news0.xs4all.nl>,
Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:
>In article <5g61g0$hak$2@news.demos.su>,
>Andrew A. Vasilyev  <andy@snm.demos.su> wrote:
>>  getpagesize() works fine, but you've not answered the question: why is
>>  it necessary to align maped region on page boundary?
>
>I had some systems barf if I didn't align on a page boundary, I think it
>was some Linux version, might be related to the libc version... and it
>says in the manual page somewhere that it should be aligned on a pagesize,
>so I decided to play it safe.

I later learned that other places in the innd source do not bother to align
on a pagesize, so when I redo this patch for the next version of inn, I'll
leave this part out (unless the other mmaps get updated too :). It does
no harm, however.

[...]
>Actually there were several bugs dwelling
>in that part of the code, apparently I was a bit sleepy when I wrote that.
>Another (incremental) patch included below.

That patch didn't quite do what it had to do. I include yet another
incremental patch below, but note that it's really much easier to start
with a clean 1.5.1 source and get the patch from my homepage:
http://www.xs4all.nl/~johnpc/inn/mmap-overview.patch. The patch below
basically undoes everything the previous patch does and then does it
right. Only for those that installed the previous patch. Really. :)

(James, this is a kind request to also update the file on ftp.isc.org,
this version has a lot of bugs fixed)

Note for anyone who's concerned: the bugs in the previous patched didn't
corrupt any data, they just had a performance impact, mostly because the
OVERgen() routine was being called more often than necessary.

--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`


--- article.c	1997/03/17 09:47:36	1.37
+++ article.c	1997/03/19 12:12:10
@@ -1,4 +1,4 @@
-/*  $Revision: 1.37 $
+/*  $Revision: 1.39 $
 **
 **  Article-related routines.
 */
@@ -11,6 +11,7 @@
 /*
  * OVERSCREAM - to make the overview database screaming fast, and because
  * I scream in terror about the previous implementation.
+ * See http://www.xs4all.nl/~johnpc/inn/ for more information on this patch.
  */
 
 #define OVERSCREAM
@@ -804,8 +805,6 @@
     struct stat 	sb;
     char*		p;
     static int		pagesize = 0;
-    int			hadlf;
-
 
     /* return true if already mapped */
     if ( OVERshm ) {
@@ -866,7 +865,7 @@
     }
 
     /* get last entry */
-    if ( !(hadlf = *(OVERshm + OVERsize - 1) == '\n') ) {
+    if ( *(OVERshm + OVERsize - 1) != '\n' ) {
 	/*
 	 * If you get here, then your mmap() implementation sucks.
 	 * Go complain with your OS vendor, that their mmap() can't
@@ -879,38 +878,32 @@
 	YOUR_MMAP_SUCKS;
     }
     do {
-	p = memrchr(OVERshm + OVERsize - 2, '\n', OVERsize - 2);
+	/*
+         * Try to find any newline. If there isn't any, the entire file
+	 * is crap. Normally this finds the newline right at the end.
+	 */
+	p = memrchr(OVERshm + OVERsize - 1, '\n', OVERsize - 1);
 	if ( p == NULL ) {
-	    if ( hadlf ) {
-		/* Apparently only 1 (usable) line */
-		OVERlast = OVERfirst;
-		OVERcache = NULL;
-		return TRUE;
-	    }
-	    else {
-		/* overview file only contains garbage. */
-		(void)munmap(OVERshm, OVERmsize);
-		(void)close(OVERfd);
-		OVERshm = NULL;
-		return FALSE;
-	    }
-	}
-	hadlf = TRUE;
-	OVERsize = p - OVERshm + 1;
-	if ( (p = memrchr((char*) OVERshm + OVERsize - 2, '\n',
-			    OVERsize - 1)) == NULL )
-	{
-	    syslog(L_NOTICE, "%s: %s: bad format", ClientHost, name);
+	    /* overview file only contains garbage. */
 	    (void)munmap(OVERshm, OVERmsize);
 	    (void)close(OVERfd);
 	    OVERshm = NULL;
 	    return FALSE;
 	}
+	OVERsize = p - OVERshm + 1;
+	if ( (p = memrchr((char*) OVERshm + OVERsize - 2, '\n',
+			    OVERsize - 2)) == NULL )
+	{
+	    /* Apparently only 1 (usable) line */
+	    OVERlast = OVERfirst;
+	    OVERcache = NULL;
+	    return TRUE;
+	}
 	OVERlast = atol(p+1);
     }
-    while ( OVERlast == 0 && --OVERsize >= 2 );
+    while ( OVERlast == 0 && --OVERsize );
 
-    if ( OVERsize < 2 ) {
+    if ( !OVERsize ) {
 	(void)munmap(OVERshm, OVERmsize);
 	(void)close(OVERfd);
 	OVERshm = NULL;
--
#! ##### Jan-Pieter Cornet ##### <johnpc@xs4all.net> ##### perl
++$_;$!=$_+++$_;($:,$,,$/,$*)=$!=~/.(.)...(.)(.).(.)/;$!=$_+$_;
($@,$\,$~)=$!=~/(.)(.).(.)/; $_="$,$/$:"; $@++; $~="$~$_";($_)=
\$$=~/\((.)/;$|=++$_;$_++;$|++;$~="$~ $@$:";`$~$/$\$*$, $|>&$_`

Re: innd 1.5.1 dumps core. buffer overflow?
#16179
Author: Alan Brown
Date: Sat, 22 Mar 1997 00:00
18 lines
1304 bytes
In article <5gj50q$pqa$1@news0.xs4all.nl>,
Jan-Pieter Cornet <johnpc@xs4all.nl> wrote:

>I've never seen a parity error cause a big chunk of memory to be
>overwritten. It *can* happen, of course, it's just extremely
>unlikely.

I suggest you read Linux FAQs then.

AB
-- 
o Stamp out unauthorised relay-hosting. This SMTP "feature" shouldn't default 
  "on" - See http://www.vix.com/spam/ and http://www.sendmail.org/antispam.html
o Junk email returned, in bulk, back to sender; w/copies to all postmasters.
o Received junkmail constitutes a request for aggressive site security probing.

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads