diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-06-20 02:24:40 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-06-20 02:24:40 +0000 |
commit | c2201e153e701130fbd08c75765b330f9280144f (patch) | |
tree | 2486817a616731edd1f5e98834c12ed2b786a044 /mansearch.c | |
parent | 4b68a3c80b4d2c00a2dd66f531e52f4677a118c6 (diff) | |
download | mandoc-c2201e153e701130fbd08c75765b330f9280144f.tar.gz mandoc-c2201e153e701130fbd08c75765b330f9280144f.tar.zst mandoc-c2201e153e701130fbd08c75765b330f9280144f.zip |
Merge from OpenBSD - Marc Espie improved the ohash interface:
* rename the halloc callback to calloc, provide overflow protection
* rename the hfree callback to free, drop the useless size argument
* prevent integer overflows in ohash_resize
Diffstat (limited to 'mansearch.c')
-rw-r--r-- | mansearch.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/mansearch.c b/mansearch.c index f9892218..7f554b27 100644 --- a/mansearch.c +++ b/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.36 2014/04/23 21:06:41 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.37 2014/06/20 02:24:40 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -85,8 +85,8 @@ static void buildnames(struct manpage *, sqlite3 *, static char *buildoutput(sqlite3 *, sqlite3_stmt *, uint64_t, uint64_t); static void *hash_alloc(size_t, void *); -static void hash_free(void *, size_t, void *); -static void *hash_halloc(size_t, void *); +static void hash_free(void *, void *); +static void *hash_calloc(size_t, size_t, void *); static struct expr *exprcomp(const struct mansearch *, int, char *[]); static void exprfree(struct expr *); @@ -171,11 +171,9 @@ mansearch(const struct mansearch *search, unsigned int idx; size_t i, j, cur, maxres; - memset(&info, 0, sizeof(struct ohash_info)); - - info.halloc = hash_halloc; + info.calloc = hash_calloc; info.alloc = hash_alloc; - info.hfree = hash_free; + info.free = hash_free; info.key_offset = offsetof(struct match, pageid); *sz = cur = maxres = 0; @@ -790,10 +788,10 @@ exprfree(struct expr *p) } static void * -hash_halloc(size_t sz, void *arg) +hash_calloc(size_t nmemb, size_t sz, void *arg) { - return(mandoc_calloc(1, sz)); + return(mandoc_calloc(nmemb, sz)); } static void * @@ -804,7 +802,7 @@ hash_alloc(size_t sz, void *arg) } static void -hash_free(void *p, size_t sz, void *arg) +hash_free(void *p, void *arg) { free(p); |