diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2011-11-13 00:53:13 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2011-11-13 00:53:13 +0000 |
commit | 46955ad8d1419acfe1267839bde6caaf5e339aa0 (patch) | |
tree | c86df2c79c1427209890d6c55f7b35b4bb476693 /mandocdb.c | |
parent | 84580dd785cd13f0304bc07505a958f6ef97ee5c (diff) | |
download | mandoc-46955ad8d1419acfe1267839bde6caaf5e339aa0.tar.gz |
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.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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); } |