🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #17749

very large path line crashes innd

#17749
From: Keith Lewis
Date: Tue, 13 May 1997 00:00
288 lines
9312 bytes

-----BEGIN PGP SIGNED MESSAGE-----


Hi Folks,

	I run a pair of news servers.  One exchanges news with other sites,
and the other handles almost all the nnrp traffic for the University.

	The first is called Harbinger, the second is called Towncrier.

	They both run inn 1.5.1.  The second is a slave to the first.

	Today a message arrived with a very large path line:


| # more /news/soc/culture/singapore/272235
| Path:harbinger.cc.monash.edu.au!msunews!news.mtu.edu!newsxfer.itd.umich.edu!\
| news.izzy.net!news.good.net!news.good.net!news.getnet.com!out2.nntp.cais.net!\
| news2.cais.com!news.intr.net!news.charm.net!news.clark.net!hustle.rahul.net!\
| rahul.net!a2i!bug.rahul.net!rahul.net!a2i!nntp.mainstreet.net!news.walltech.com!\
| daver!news.he.net!calwebnntp!news.eli.net!news.wolsi.com!news.aros.net!\
| news.uoregon.edu!news.acsu.buffalo.edu!dsinc!newsfeed.pitt.edu!portc02.blue.\
| aol.com!howland.erols.net!blackbush.xlink.net!news-kar1.dfn.de!news-fra1.dfn.de!\
| news-ber1.dfn.de!zrz.TU-Berlin.DE!stern.fokus.gmd.de!nntp.gmd.de!newsserver.\
| jvnc.net!news.merck.com!cam-news-feed1.bbnplanet.com!cam-news-hub1.bbnplanet.\
| com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!cam-news-feed2.bbnplanet.\
| com!bigboote.WPI.EDU!news.ultranet.com!zombie.ncsc.mil!news.missouri.edu!ukma!\
| news.memphis.edu!nntp.msstate.edu!gatech!csulb.edu!hammer.uoregon.edu!news.\
| ironhorse.com!nntp.portal.ca!van-bc!n1van.istar!van.istar!west.istar!news-\
| w.ans.net!newsfeeds.ans.net!lantana.singnet.com.sg!usenet
| From: Anonymous
| Newsgroups: soc.culture.singapore
| Subject: Hello.
| Date: -
| Organization: Singapore Telecom Internet Service
| Lines: 3
| Distribution: world
| Message-ID: <ALmpw9pCs0@Alamak>
| NNTP-Posting-Host: ts900-6929.singnet.com.sg
| Mime-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Xref: harbinger.cc.monash.edu.au soc.culture.singapore:272235
| 
| hello. How is everybody here.
|

	Now somehow that message got accepted by Harbinger, and passed on to
Towncrier using the xreplic protocol.  

	At which point Towncrier died a dismal death.

	innd didn't write any log anywhere, just dropped core in the news
spool.

	Analysing the core I proceeded as follows:

# dbx /usr/local/etc/innd ./core
dbx version 3.11.10
Type 'help' for help.
Core file created by program "innd"

signal Segmentation fault at >*[NLstrdlen, 0x3ff800d1870] ldq_u r1, 0(r16)
(dbx) where
> 0 NLstrdlen(0x2d, 0x11fffe980, 0x3ff00000010, 0x140012a00,
0x7ff0000000000000) [0x3ff800d1870]
   1 HISsetkey(p = (nil), keyp = 0x11fffe9f8) ["his.c":104, 0x1200169c4]
   2 HISwrite(Data = 0x11fffea88, paths = 0x140001aa8 = "") ["his.c":245,
0x1200170f8]
   3 ARTpost(cp = 0x14001a7c0, Replic = 0x14014df38, ihave = (nil))
["art.c":1787, 0x12000ba68]
   4 NCpostit(cp = 0x14001a7c0) ["nc.c":235, 0x12001c568]
   5 NCproc(cp = 0x14001a7c0) ["nc.c":1086, 0x12001fdb0]
   6 NCreader(cp = 0x14001a7c0) ["nc.c":1311, 0x12002098c]
   7 CHANreadloop() ["chan.c":873, 0x120015db0]
   8 main(ac = 0, av = 0x11ffffd28) ["innd.c":952, 0x12001b2d4]
(dbx) 


	OK, starting at the top, segfault.  Presumably strlen called with a
null pointer.

	Looking at the source of HISsetkey 

STATIC void
HISsetkey(p, keyp)
    register char       *p;
    datum               *keyp;
{
    static BUFFER       MessageID;
    register char       *dest;
    register int        i;

    /* Get space to hold the ID. */
    i = strlen(p);

	Yep.  Strlen called with a null allright.

	But why?  What was HISwrite doing?

BOOL
HISwrite(Data, paths)
    ARTDATA             *Data;
    char                *paths;
{
    static char         NOPATHS[] = "";
    long                offset;
    datum               key;
    datum               val;
    int                 i;

    HISsetkey(Data->MessageID, &key);

	Is MessageID blank?

(dbx) func HISwrite
HISwrite:        Source not available
(dbx) print Data
0x11fffea88 
(dbx) print *Data
struct {
    Poster = 0x14014a8c0 = ""
    Replyto = 0x14014a8c0 = ""
    Body = 0x1404a3000 = "Path:
harbinger.cc.monash.edu.au!msunews!news.mtu.edu!newsxfer.itd.umich.edu!news.izzy.net!news.good.net!news.good.net!news.getnet.com!o\..."
    Posted = 863304370
    Arrived = 863483145
    Expires = 0
    Groupcount = 1
    LinesValue = 6
    Lines = ""
    SizeValue = 951
    Size = ""
    SizeLength = 3
    Name = "alt/2600/hope/announce/4253"
    NameLength = 27
    TimeReceived = "863483145"
    TimeReceivedLength = 9
    MessageID = (nil)
    MessageIDLength = 36
    Newsgroups = 0x1404a2d00 = "alt.2600.hope.announce"
    NewsgroupsLength = 22
    Distribution = 0x140001958 = "?"
More (n if no)?
    DistributionLength = 1
    Feedsite = 0x1400140f0 = "harbinger.cc.monash.edu.au"
    FeedsiteLength = 26
    Replic = 0x1404a2c80 = "alt.2600.hope.announce/4253"
    ReplicLength = 27
    Headers = 0x3ff80091f39
    Overview = 0x140008140
} 
(dbx) 

	Yep.  Sure is.  So where did that come from?
	Looking in art.c line 1787

    /* Now see if we got an error in the article. */
    if (error != NULL) {
        (void)sprintf(buff, "%d %s", NNTP_REJECTIT_VAL, error);
        ARTlog(&Data, ART_REJECT, buff);
#if     defined(DO_REMEMBER_TRASH)
        if (Mode == OMrunning && !HISwrite(&Data, ""))		<------------
            syslog(L_ERROR, "%s cant write history %s %m",
                   LogName, Data.MessageID);
#endif  /* defined(DO_REMEMBER_TRASH) */
        ARTreject(buff, article);
        return buff;
    }

	While we are here, lets print out buff:

(dbx) print buff
"437 "Path" header too long" 
(dbx) 

	But what we really want to know is why is 

(dbx) print Data.MessageID
(nil) 
(dbx) 

	Going up to NCpostit:

    case OMrunning:
        wp = &NCwip[cp->fd];
        response = ARTpost(cp, AmSlave ? &wp->Replic : NULL, wp->MessageID);

(dbx) func NCpostit
NCpostit:        Source not available
(dbx) print wp->MessageID
(nil) 
(dbx) 

	Going up further, to NCproc, 

(dbx) func NCproc
NCproc:  Source not available
(dbx)

(dbx) print NCwip[16]
struct {
    MessageID = (nil)
    Size = 0
    Timestamp = 863483145
    Replic = struct {
        Size = 29
        Used = 29
        Left = 29
        Data = 0x1403d2970 = "soc.culture.singapore/272235"
    }
    Wanted = 0
} 
(dbx) 

	So we have to go up even more to find why MessageID is nill.
 
	looking at line 1086 in NCproc:

            /* Strip article terminator and post the article. */
            p[-3] = '\0';
            bp->Used -= 2;
            SCHANremove(cp);
            if (cp->Argument != NULL) {
                DISPOSE(cp->Argument);
                cp->Argument = NULL;
            }
            NCclean(bp);
            NCpostit(cp);			<---------------
            cp->State = CSgetcmd;
            break;


	Right... thats the problem...  Immediately before NCpostit is
NCclean which called ARTparseheader:

    for (error = NULL, in = out = Article->Data; ; out += delta, in = p) {
	...
        /* Check the validity of this header. */
        if ((p = ARTparseheader(in, out, &delta, &error)) == NULL)
            break;
    }
    Data->Body = out;
    in++;

    /* Try to set this now, so we can report it in errors. */
    p = HDR(_message_id);


	What went wrong was that ARTparseheader failed on the first header,
and hence broke out of the loop without parsing messageid.  Hence the line
p = HDR(_message_id), which, defined in art.h, expands to #define HDR(_x)
(ARTheaders[(_x)].Value), returned nil.  Hence the rest of the story.

	So what to do?

	Well, in the loop in NCclean we could be changed to not break on
errors...  That way all headers would be tested, and the last error, if any
would be returned.  Rather than the first.  So if a message id exists we will
find it and be able to do the history add and so on.

	Another thing we could do is not try and add items to history if
their headers are faulty...  i.e. `if ( p == NULL ) return;' at the top of  
HISwrite, or ARTpost...

	Actualy I guess there are lots of better alternatives.

	So finally my question:  `Is this a known bug, and is there an
official fix?'

Keith Lewis


-----BEGIN PGP SIGNATURE-----
Version: 2.6.2i

iQCVAwUBM3gSUXEpE0nRVDfpAQE9gwQAvol3PtvCPJCr4r/LxgN6dgOlw/UkzRnz
8AqJjMjFxA1niDFZgX97a3969rHALI8/gwb6KJyobmPGV+uq3fAol9bIEWtF2ooz
O7HBiFXP3TlopzM2QN+ngPtQQJ9zpHsB+XT0kicC0h6ilAlpxicSDZJgrrCg0D9t
IGyaUyzbl2o=
=3E+e
-----END PGP SIGNATURE-----

	

Technical Details
Message-ID: <5l93pr$3jm$1@towncrier.cc.monash.edu.au>
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

Show Full Headers
Complete Article Headers
Message-ID: <5l93pr$3jm$1@towncrier.cc.monash.edu.au>
Subject: very large path line crashes innd
Date: Tue, 13 May 1997 00:00:00 +0000
From: keithl@mukluk.cc.monash.edu.au (Keith Lewis)
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: 241242400
X-NNTP-Posting-User: keithl
Summary: null mess id causes segfault
Organization: Monash Uni
Keywords: NCpostit NCclean ARTparseheader
Newsgroups: news.software.nntp