summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-23 21:06:41 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-23 21:06:41 +0000
commitd14278c71c190ee93f3a8fbe0db5fe9f64fcee24 (patch)
treeb979660d5a5719053862183ee172a781e317d0ba /mandocdb.c
parentbd8fc166fb7a4aad04578dee7fe7fc209d5e1488 (diff)
downloadmandoc-d14278c71c190ee93f3a8fbe0db5fe9f64fcee24.tar.gz
Audit malloc(3)/calloc(3)/realloc(3) usage.
* Change eight reallocs to reallocarray to be safe from overflows. * Change one malloc to reallocarray to be safe from overflows. * Change one calloc to reallocarray, no zeroing needed. * Change the order of arguments of three callocs (aesthetical).
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 88a2968b..e35501c4 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -471,8 +471,8 @@ main(int argc, char *argv[])
* manpath_parse() wants to do it.
*/
if (argc > 0) {
- dirs.paths = mandoc_calloc(argc,
- sizeof(char *));
+ dirs.paths = mandoc_reallocarray(NULL,
+ argc, sizeof(char *));
dirs.sz = (size_t)argc;
for (i = 0; i < argc; i++)
dirs.paths[i] = mandoc_strdup(argv[i]);
@@ -1784,7 +1784,7 @@ putkeys(const struct mpage *mpage,
s->mask |= v;
return;
} else if (NULL == s) {
- s = mandoc_calloc(sizeof(struct str) + sz + 1, 1);
+ s = mandoc_calloc(1, sizeof(struct str) + sz + 1);
memcpy(s->key, cp, sz);
ohash_insert(htab, slot, s);
}
@@ -2314,7 +2314,7 @@ static void *
hash_halloc(size_t sz, void *arg)
{
- return(mandoc_calloc(sz, 1));
+ return(mandoc_calloc(1, sz));
}
static void *