aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-11-13 00:53:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-11-13 00:53:13 +0000
commit97939338caf927c795ebb780aac3e38f213d3e7c (patch)
tree4a400f8ef2dfea4f985b198722749b8324b64f1f /mandocdb.c
parent8f033b9ec35601ec57fb7ccde390d68c8a51165a (diff)
downloadmandoc-97939338caf927c795ebb780aac3e38f213d3e7c.tar.gz
mandoc-97939338caf927c795ebb780aac3e38f213d3e7c.tar.zst
mandoc-97939338caf927c795ebb780aac3e38f213d3e7c.zip
Fix two crashes that occur when walking very large (i.e. real-world) trees:
1) Avoid excessive, needless recursion, lest you overflow the stack; 2) Close all dir file descriptors, lest you run out of descriptors. ok kristaps@
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mandocdb.c b/mandocdb.c
index d9f57416..7e2b4a54 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.6 2011/09/17 13:54:27 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.7 2011/11/13 00:53:13 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -1168,10 +1168,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);
}
@@ -1276,6 +1275,7 @@ ofile_dirbuild(const char *dir, int verb, struct of **of)
}
}
+ closedir(d);
return(1);
}