From a6843f2d1ecf58a3ec2d015f7d379f923fb14528 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 23 Apr 2014 21:31:38 +0000 Subject: Audit malloc(3)/calloc(3)/realloc(3) in VERSION_1_12. --- Makefile | 3 +++ apropos_db.c | 6 +++--- configure | 1 + mandocdb.c | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7069201a..a453f888 100644 --- a/Makefile +++ b/Makefile @@ -65,6 +65,7 @@ TESTSRCS = test-betoh64.c \ test-fgetln.c \ test-getsubopt.c \ test-mmap.c \ + test-reallocarray.c \ test-strlcat.c \ test-strlcpy.c \ test-strnlen.c \ @@ -89,6 +90,7 @@ SRCS = LICENSE \ chars.in \ compat_fgetln.c \ compat_getsubopt.c \ + compat_reallocarray.c \ compat_strcasestr.c \ compat_strlcat.c \ compat_strlcpy.c \ @@ -212,6 +214,7 @@ LIBMANDOC_OBJS = $(LIBMAN_OBJS) \ COMPAT_OBJS = compat_fgetln.o \ compat_getsubopt.o \ + compat_reallocarray.o \ compat_strcasestr.o \ compat_strlcat.o \ compat_strlcpy.o \ diff --git a/apropos_db.c b/apropos_db.c index f96c94f9..2eee2091 100644 --- a/apropos_db.c +++ b/apropos_db.c @@ -1,4 +1,4 @@ -/* $Id: apropos_db.c,v 1.32.2.5 2014/03/23 12:04:54 schwarze Exp $ */ +/* $Id: apropos_db.c,v 1.32.2.6 2014/04/23 21:31:38 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2014 Ingo Schwarze @@ -555,8 +555,8 @@ single_search(struct rectree *tree, const struct opts *opts, if (strcasecmp(opts->arch, r.arch)) continue; - tree->node = rs = mandoc_realloc - (rs, (tree->len + 1) * sizeof(struct res)); + tree->node = rs = mandoc_reallocarray(rs, + tree->len + 1, sizeof(struct res)); memcpy(&rs[tree->len], &r, sizeof(struct res)); memset(&r, 0, sizeof(struct res)); diff --git a/configure b/configure index be5d38c6..d119c567 100755 --- a/configure +++ b/configure @@ -34,6 +34,7 @@ runtest betoh64 BETOH64 runtest fgetln FGETLN runtest getsubopt GETSUBOPT runtest mmap MMAP +runtest reallocarray REALLOCARRAY runtest strcasestr STRCASESTR runtest strlcat STRLCAT runtest strlcpy STRLCPY diff --git a/mandocdb.c b/mandocdb.c index 05ab11cf..99a300d8 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.49.2.15 2014/03/23 12:37:58 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.49.2.16 2014/04/23 21:31:38 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012 Ingo Schwarze @@ -984,8 +984,8 @@ index_prune(const struct of *ofile, struct mdb *mdb, struct recs *recs) cont: if (recs->cur >= recs->size) { recs->size += MANDOC_SLOP; - recs->stack = mandoc_realloc(recs->stack, - recs->size * sizeof(recno_t)); + recs->stack = mandoc_reallocarray(recs->stack, + recs->size, sizeof(recno_t)); } recs->stack[(int)recs->cur] = recs->last; -- cgit v1.2.3