From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s3NLVdIO002578 for ; Wed, 23 Apr 2014 17:31:39 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s3NLVdkt004791; Wed, 23 Apr 2014 17:31:39 -0400 (EDT) Date: Wed, 23 Apr 2014 17:31:39 -0400 (EDT) Message-Id: <201404232131.s3NLVdkt004791@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Audit malloc(3)/calloc(3)/realloc(3) in VERSION_1_12. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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