From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32359 invoked from network); 11 Aug 2021 15:10:07 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2021 15:10:07 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id f1b82a6e for ; Wed, 11 Aug 2021 10:10:04 -0500 (EST) Received: from scc-mailout-kit-02.scc.kit.edu (scc-mailout-kit-02.scc.kit.edu [129.13.231.82]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 0bde03f2 for ; Wed, 11 Aug 2021 10:10:03 -0500 (EST) Received: from hekate.asta.kit.edu ([141.3.145.153] helo=hekate.usta.de) by scc-mailout-kit-02.scc.kit.edu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (envelope-from ) id 1mDprl-0008AU-QL; Wed, 11 Aug 2021 17:10:02 +0200 Received: from donnerwolke.asta.kit.edu ([141.3.145.61] helo=donnerwolke.usta.de) by hekate.usta.de with esmtp (Exim 4.92.2) (envelope-from ) id 1mDprk-0007l7-5D; Wed, 11 Aug 2021 17:10:00 +0200 Received: from athene.asta.kit.edu ([141.3.145.60] helo=athene.usta.de) by donnerwolke.usta.de with esmtp (Exim 4.84_2) (envelope-from ) id 1mDprj-0006vb-V8; Wed, 11 Aug 2021 17:10:00 +0200 Received: from localhost (athene.usta.de [local]) by athene.usta.de (OpenSMTPD) with ESMTPA id 6d09e37c; Wed, 11 Aug 2021 17:09:59 +0200 (CEST) Date: Wed, 11 Aug 2021 17:09:59 +0200 From: Ingo Schwarze To: sternenseemann@systemli.org Cc: tech@mandoc.bsd.lv Subject: Re: makewhatis: segfault in dbadd when using -a Message-ID: <20210811150959.GI38774@athene.usta.de> References: X-Mailinglist: mandoc-tech Reply-To: tech@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Hi Lukas, sorry for the delay in addressing a bug as serious as a segfault. I got distracted by bugfixing in date(1), editline(3), less(1), sftp(1), and tbl(7). A clear case of silly season: everyone is on holiday and no one reports any bugs, right? Right. Or perhaps not... :) sternenseemann wrote on Sat, Aug 07, 2021 at 01:53:18AM +0200: > while testing Ingo's latest patch I found a segfault in makewhatis > involving -a and symlinks which I can also reproduce on unpatched CVS. > > To reproduce do something like this > > mkdir test-manpath > mkdir -p test-manpath/de/man1 > ln -sf $(realpath test-manpath/de) test-manpath/DE Whoa. A symlink inside a manpath that points to a directory? I must admit it never crossed my mind that people might do something like that. No excuse for crashing, of course. > So we have a base directory which has one child that is a symlink. This > symlink points to a directory below the base directory which contains > another directory. Running makewhatis -a test-manpath will then segfault [...] > I've stared at mpages_merge for a little bit, but haven't figured out "Nothing to see here, move on!" You stared at the wrong place. That may be where the car finally exploded, but not where it ran off the road. Note that i don't feel like actually *following* such a link unless people show real-world use cases that require it. If the link target is below the same manpath, it will be reached by direct traversal, too. Nobody claimed so far that having such a link point to the cellar or store might be useful, and if i understand sufficiently well what the point of a cellar or a store is, indeed it could hardly be useful. If it points somewhere else, it certainly should not be followed. Does the following patch make sense to you and work for you? Thanks for the report, Ingo Index: mandocdb.c =================================================================== RCS file: /cvs/src/usr.bin/mandoc/mandocdb.c,v retrieving revision 1.216 diff -u -p -U7 -r1.216 mandocdb.c --- mandocdb.c 3 Apr 2020 11:34:19 -0000 1.216 +++ mandocdb.c 11 Aug 2021 15:05:58 -0000 @@ -588,14 +588,16 @@ treescan(void) } /* Use logical inode to avoid mpages dupe. */ if (stat(path, ff->fts_statp) == -1) { if (warnings) say(path, "&stat"); continue; } + if ((ff->fts_statp->st_mode & S_IFMT) != S_IFREG) + continue; /* FALLTHROUGH */ /* * If we're a regular file, add an mlink by using the * stored directory data and handling the filename. */ case FTS_F: -- To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv