🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #70427

Re: [INN] Found: OpenArticle/CAFOpenArtRead() lseek problem

#70427
From: Xavier Roche
Date: Mon, 13 Dec 2004 13:26
30 lines
2516 bytes
Okay, I probably found the bug.

Scenario:
- inn.conf with 'articlemmap: true'
- a truncated .CF file somewhere

In OpenArticle()
timecaf.c:432 ->
	CAFOpenArtRead()
caf.c:592 ->
	lseek(fd, tocent.Offset, SEEK_SET)
	[ with an out-of-bound tocent.Offset (truncated file) ]
timecaf.c:463 ->
	mmap(NULL, private->mmaplen, PROT_READ, MAP_SHARED, fd, tmpoff)
	[ with an ot-of-bound file position ]

Unfortunately,
- lseek() successfully sets the pointer beyond the end of file (POSIX: 
"The lseek() function shall allow the file offset to be set beyond the 
end of the existing data in the file." - see 
<http://www.opengroup.org/onlinepubs/009695399/functions/lseek.html>)
- mmap returns a non-NULL pointer with an invalid mapped area, raising 
SIGBUS upon read inside the zone (POSIX: "References within the address 
range starting at pa and continuing for len bytes to whole pages 
following the end of an object shall result in delivery of a SIGBUS 
signal" - 
<http://www.opengroup.org/onlinepubs/009695399/functions/mmap.html>)

Hence, using 'articlemmap: true' is probably currently dangerous if you 
are recovering a damaged database with something like makehistory -O
Technical Details
Message-ID: <cpk59v$lat$1@news.httrack.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!tiscali!newsfeed1.ip.tiscali.net!proxad.net!213.246.39.15.MISMATCH!async2!news.httrack.net!not-for-mail
References: <cp90co$69d$1@news.httrack.net> <cp96g5$bnk$1@puck.litech.org> <cp996m$7bp$1@news.httrack.net>

Show Full Headers
Complete Article Headers
Message-ID: <cpk59v$lat$1@news.httrack.net>
Subject: Re: [INN] Found: OpenArticle/CAFOpenArtRead() lseek problem
Date: Mon, 13 Dec 2004 14:26:18 +0100
From: Xavier Roche <xroche@free.fr.NOSPAM.invalid>
References: <cp90co$69d$1@news.httrack.net> <cp96g5$bnk$1@puck.litech.org> <cp996m$7bp$1@news.httrack.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!tiscali!newsfeed1.ip.tiscali.net!proxad.net!213.246.39.15.MISMATCH!async2!news.httrack.net!not-for-mail
Newsgroups: news.software.nntp
Organization: Nowhere Corp.
Lines: 30
NNTP-Posting-Host: gw.exalead.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.httrack.net 1102944383 21853 212.234.111.157 (13 Dec 2004
X-Complaints-To: usenet@httrack.com
NNTP-Posting-Date: Mon, 13 Dec 2004 13:26:23 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
X-Accept-Language: fr, en-us, en, ja
In-Reply-To: <cp996m$7bp$1@news.httrack.net>