πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #92559

Re: innd SERVER cant malloc 18446744073699012160 bytes

#92559
From: Russ Allbery
Date: Tue, 18 Nov 2025 19:08
48 lines
2958 bytes
Julien Γ‰LIE <iulius@nom-de-mon-site.com.invalid> writes:

> I am wondering whether ARTxrefslave does the right thing if the Xref
> header field is badly formatted.
> For instance "Xref: group:10\r\n" without a server name.

>     if (!HDR_FOUND(HDR__XREF))
>         return false;
>     /* skip server name */
>     if ((p = strpbrk(HDR(HDR__XREF), " \t\r\n")) == NULL)
>         return false;
>     /* in case Xref is folded */
>     while (*++p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
>         ;
>     if (*p == '\0')
>         return false;
>     data->Replic = p;
>     data->ReplicLength = HDR_LEN(HDR__XREF) - (p - HDR(HDR__XREF));

> I think p would point at the beginning of the following header field, or
> the beginning of the body, and then:
> data->ReplicLength = strlen("group:10") - strlen("group:10\r\n") = -2

Oh, good catch! I was staring at exactly that piece of code because it
looked rather suspicious to me on first glance with all the pointer math,
but then I couldn't see how it failed.

I think the problem you identify could be fixed with a check like:

    if (p > HDR(HDR__XREF) + HDR_LEN(HDR__XREF))
        return false;

after the strpbrk line. This still assumes that the full article being
processed is nul-terminated, but I think that is indeed the case.

I am still a bit confused, though, because the value of groupslen doesn't
seem to be something sensible like -2. If I'm doing the math correctly,
it's something more like -10539456, which is a hard value to justify if
the problem is the above bug. strpbrk would terminate at the first
newline, and that's a lot of characters to go without encountering a
newline. Such an article is very syntactically invalid and I would have
expected it to fail other checks.

-- 
Russ Allbery (eagle@eyrie.org)             <https://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <https://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Technical Details
Message-ID: <87tsyrf9ag.fsf@hope.eyrie.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!spool1.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.killfile.org!news.eyrie.org!.POSTED!not-for-mail
References: <10fenue$2qr8$1@nnrp.usenet.blueworldhosting.com> <10fi0nt$3uqp2$1@news.trigofacile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!spool1.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.killfile.org!news.eyrie.org!.POSTED!not-for-mail
From: Russ Allbery <eagle@eyrie.org>
Newsgroups: news.software.nntp
Subject: Re: innd SERVER cant malloc 18446744073699012160 bytes
Date: Tue, 18 Nov 2025 11:08:39 -0800
Organization: The Eyrie
Message-ID: <87tsyrf9ag.fsf@hope.eyrie.org>
References: <10fenue$2qr8$1@nnrp.usenet.blueworldhosting.com>
	<10fi0nt$3uqp2$1@news.trigofacile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: hope.eyrie.org;
	logging-data="21702"; mail-complaints-to="news@eyrie.org"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:e7ZMXMYezDYV3e2Rfpzjb9T4u+Q=