summaryrefslogtreecommitdiffstats
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
commit46955ad8d1419acfe1267839bde6caaf5e339aa0 (patch)
treec86df2c79c1427209890d6c55f7b35b4bb476693 /mandocdb.c
parent84580dd785cd13f0304bc07505a958f6ef97ee5c (diff)
downloadmandoc-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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 2e58d1db..a8057716 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -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);
}