summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2011-11-13 00:53:07 +0000
committerschwarze <schwarze@openbsd.org>2011-11-13 00:53:07 +0000
commitb1d454ab33b086f9fcffab238a94d5d7b0cfa2a7 (patch)
tree40559b756ba7fe436a325af62b1b6856898268d4
parentmark some arguments "const" that will not be changed; from kristaps@ (diff)
downloadwireguard-openbsd-b1d454ab33b086f9fcffab238a94d5d7b0cfa2a7.tar.xz
wireguard-openbsd-b1d454ab33b086f9fcffab238a94d5d7b0cfa2a7.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 dir file descriptors, lest you run out of descriptors. ok kristaps@
-rw-r--r--usr.bin/mandoc/mandocdb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index f411c2ba47a..80b9468f677 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.3 2011/10/06 23:04:16 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.4 2011/11/13 00:53:07 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -1159,10 +1159,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);
}
@@ -1267,6 +1266,7 @@ ofile_dirbuild(const char *dir, int verb, struct of **of)
}
}
+ closedir(d);
return(1);
}