From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout.scc.kit.edu (scc-mailout-webmail.scc.kit.edu [129.13.185.232]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id pAD09T6T021617 for ; Sat, 12 Nov 2011 19:09:30 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by scc-mailout-02.scc.kit.edu with esmtp (Exim 4.72 #1) id 1RPNdZ-00045q-9X; Sun, 13 Nov 2011 01:09:29 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1RPNdZ-0003xL-DI for tech@mdocml.bsd.lv; Sun, 13 Nov 2011 01:09:29 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1RPNdZ-0001ZF-CI for tech@mdocml.bsd.lv; Sun, 13 Nov 2011 01:09:29 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1RPNdZ-00000O-B1 for tech@mdocml.bsd.lv; Sun, 13 Nov 2011 01:09:29 +0100 Date: Sun, 13 Nov 2011 01:09:29 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: fix two crashes in mandocdb Message-ID: <20111113000929.GD16229@iris.usta.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, here are two easy, but important bugfixes for mandocdb(8). Chunk 1 is required such that mandocdb doesn't die on extremely long files. In my /usr/share/man tree, i have a few very large files - not real manuals, but they get in the way. The man parser produces several tens of thousands of text nodes from these files. When mandocdb.c attempts to parse them, it abuses recursion to walk a linear list, resulting in O(N) stack size requirements. Stacks with several tens of thousands of frames don't work well, the program consistently segfaulted; overflowing thew stack, i guess. With the for loop, time requirements are still O(N), but at least we get constant stack size. I guess we should scour the tree for similar bugs. This might as well crash massively oversized man(7) manuals during normal formatting. Chunk 2 is required to avoid running out of file descriptors when walking large directory trees. Otherwise, mandocdb keeps crashing on me because it hits the system resource limit on open file descriptors. Using this, i can now run # mandocdb /usr/share/man on my main development machine. OK? Ingo --- mandocdb.c.orig +++ mandocdb.c @@ -1142,10 +1142,9 @@ pman_node(MAN_ARGS) } } - if (pman_node(hash, buf, dbuf, n->child)) - return(1); - if (pman_node(hash, buf, dbuf, n->next)) - return(1); + for (n = n->child; n; n = n->next) + if (pman_node(hash, buf, dbuf, n)) + return(1); return(0); } @@ -1250,6 +1249,7 @@ ofile_dirbuild(const char *dir, int verb, struct of **of) } } + closedir(d); return(1); } -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv