🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #46206

Re: INN 2.3.0 public beta

#46206
From: Russ Allbery
Date: Sun, 30 Apr 2000 00:00
77 lines
3472 bytes
Karl Kleinpaste <karl@charcoal.com> writes:

> Well, things are looking progressively worse.  INND is now tripping over
> a SEGV in the perl handling code:

> Program received signal SIGSEGV, Segmentation fault.
> 0x400ea712 in chunk_alloc (ar_ptr=0x4017fd60, nb=24) at malloc.c:2764
> 2764    malloc.c: No such file or directory.
> (gdb) bt
> #0  0x400ea712 in chunk_alloc (ar_ptr=0x4017fd60, nb=24) at malloc.c:2764
> #1  0x400ea5ce in __libc_malloc (bytes=13) at malloc.c:2696
> #2  0x809efe5 in Perl_safemalloc ()

And... I think I found the arena corruption.  In the keywords code:

    hp->Value = malloc(innconf->keylimit+1);

The total allocated length starts at innconf->keylimit plus one byte for
the null termination.  l (the length of the keywords already in the
article) starts at:

    if (l > innconf->keylimit - (MAX_WORD_LENGTH+5))
        l = innconf->keylimit - (MAX_WORD_LENGTH+5);

And then there's a loop to copy found keywords into that space, which
starts with:

    for (chase = hp->Value + l + 2, word_index = 0;
         word_index < distinct_words;
         word_index++) {

so at the start of this loop, chase could point to a space at most
MAX_WORD_LENGTH + 4 from the end of the allocated space.  A word is copied
into that space:

        *chase++ = ',';
        strcpy(chase, word[word_vec[word_index].index]);
        chase += word_vec[word_index].length;

If the word is MAX_WORD_LENGTH long, chase now points three bytes from the
end of the allocated space.  If that's the case, we drop out of the loop:

        if (chase - hp->Value > (innconf->keylimit - (MAX_WORD_LENGTH + 4)))
            break;

but then the next code:

    /* note #words we didn't get to add. */
    if (word_index < distinct_words - 1)
        sprintf(chase, ",%d", (distinct_words - word_index) - 1);

just wrote past the end of the allocated buffer if the number of keywords
we found but couldn't add to the Keywords buffer if the number of words we
couldn't write was greater than 99.

Here's the trivial fix.  I don't trust a better fix without a lot clearer
logic to determine how much space is left.

--- art.c       2000/04/29 14:08:13     1.133
+++ art.c       2000/04/30 07:40:09
@@ -1811,9 +1811,6 @@
        if (chase - hp->Value > (innconf->keylimit - (MAX_WORD_LENGTH + 4)))
            break;
     }
-    /* note #words we didn't get to add. */
-    if (word_index < distinct_words - 1)
-       sprintf(chase, ",%d", (distinct_words - word_index) - 1);
     hp->Length = strlen(hp->Value);
 
 out:

Could you try this and see if it fixes your problem?

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

Technical Details
Message-ID: <ylln1wghnk.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <yl7ldiu3j8.fsf@windlord.stanford.edu> <vxkg0s6t1oi.fsf@mesquite.charcoal.com> <vxk4s8msziu.fsf@mesquite.charcoal.com>

Show Full Headers
Complete Article Headers
Message-ID: <ylln1wghnk.fsf@windlord.stanford.edu>
Subject: Re: INN 2.3.0 public beta
Date: Sun, 30 Apr 2000 00:00:00 +0000
From: Russ Allbery <rra@stanford.edu>
References: <yl7ldiu3j8.fsf@windlord.stanford.edu> <vxkg0s6t1oi.fsf@mesquite.charcoal.com> <vxk4s8msziu.fsf@mesquite.charcoal.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 617422805
Content-Type: text/plain; charset=us-ascii
Organization: The Eyrie
Mime-Version: 1.0
User-Agent: Gnus/5.0802 (Gnus v5.8.2) XEmacs/21.1 (Biscayne)
Newsgroups: news.software.nntp