source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Audit malloc(3)/calloc(3)/realloc(3) in VERSION_1_12.
@ 2014-04-23 21:31 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-04-23 21:31 UTC (permalink / raw)
  To: source

Log Message:
-----------
Audit malloc(3)/calloc(3)/realloc(3) in VERSION_1_12.

Tags:
----
VERSION_1_12

Modified Files:
--------------
    mdocml:
        Makefile
        apropos_db.c
        cgi.c
        configure
        mandocdb.c

Revision Data
-------------
Index: apropos_db.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Attic/apropos_db.c,v
retrieving revision 1.32.2.5
retrieving revision 1.32.2.6
diff -Lapropos_db.c -Lapropos_db.c -u -p -r1.32.2.5 -r1.32.2.6
--- apropos_db.c
+++ apropos_db.c
@@ -555,8 +555,8 @@ single_search(struct rectree *tree, cons
 			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));
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.49.2.15
retrieving revision 1.49.2.16
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.49.2.15 -r1.49.2.16
--- mandocdb.c
+++ mandocdb.c
@@ -984,8 +984,8 @@ index_prune(const struct of *ofile, stru
 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;
Index: configure
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/configure,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -Lconfigure -Lconfigure -u -p -r1.1.2.2 -r1.1.2.3
--- configure
+++ 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
Index: cgi.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v
retrieving revision 1.50
retrieving revision 1.50.2.1
diff -Lcgi.c -Lcgi.c -u -p -r1.50 -r1.50.2.1
--- cgi.c
+++ cgi.c
@@ -936,7 +936,7 @@ pg_search(const struct req *req, char *p
 		ep++;
 
 	while (ep && '\0' != *ep) {
-		cp = mandoc_realloc(cp, (sz + 1) * sizeof(char *));
+		cp = mandoc_reallocarray(cp, sz + 1, sizeof(char *));
 		start = ep;
 		while ('\0' != *ep && ! isspace((unsigned char)*ep))
 			ep++;
@@ -1180,9 +1180,8 @@ pathgen(DIR *dir, char *path, struct req
 	if (rc > 0) {
 		/* This also strips the trailing slash. */
 		path[(int)--sz] = '\0';
-		req->p = mandoc_realloc
-			(req->p, 
-			 (req->psz + 1) * sizeof(struct paths));
+		req->p = mandoc_reallocarray(req->p, 
+		    req->psz + 1, sizeof(struct paths));
 		/*
 		 * Strip out the leading "./" unless we're just a ".",
 		 * in which case use an empty string as our name.
Index: Makefile
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Makefile,v
retrieving revision 1.395.2.16
retrieving revision 1.395.2.17
diff -LMakefile -LMakefile -u -p -r1.395.2.16 -r1.395.2.17
--- Makefile
+++ 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 \
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-23 21:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 21:31 mdocml: Audit malloc(3)/calloc(3)/realloc(3) in VERSION_1_12 schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).