source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: merge rev.
@ 2020-06-14 23:09 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2020-06-14 23:09 UTC (permalink / raw)
  To: source

Log Message:
-----------
merge rev. 1.58 from OpenBSD (deraadt@):
recallocarray() the string buffer, to avoid leaving such contents
around in the address space.  Don't bother doing so for the buffer
which contains aslr'd pointers...
OK millert@

Modified Files:
--------------
    mandoc:
        compat_fts.c

Revision Data
-------------
Index: compat_fts.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/compat_fts.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lcompat_fts.c -Lcompat_fts.c -u -p -r1.15 -r1.16
--- compat_fts.c
+++ compat_fts.c
@@ -7,7 +7,7 @@ int dummy;
 #else
 
 /*	$Id$	*/
-/*	$OpenBSD: fts.c,v 1.56 2016/09/21 04:38:56 guenther Exp $	*/
+/*	$OpenBSD: fts.c,v 1.59 2019/06/28 13:32:41 deraadt Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -575,14 +575,14 @@ fts_sort(FTS *sp, FTSENT *head, int nite
 	if (nitems > sp->fts_nitems) {
 		struct _ftsent **a;
 
-		sp->fts_nitems = nitems + 40;
 		if ((a = reallocarray(sp->fts_array,
-		    sp->fts_nitems, sizeof(FTSENT *))) == NULL) {
+		    nitems + 40, sizeof(FTSENT *))) == NULL) {
 			free(sp->fts_array);
 			sp->fts_array = NULL;
 			sp->fts_nitems = 0;
 			return (head);
 		}
+		sp->fts_nitems = nitems + 40;
 		sp->fts_array = a;
 	}
 	for (ap = sp->fts_array, p = head; p; p = p->fts_link)
@@ -651,13 +651,14 @@ fts_palloc(FTS *sp, size_t more)
 		errno = ENAMETOOLONG;
 		return (1);
 	}
-	sp->fts_pathlen += more;
-	p = realloc(sp->fts_path, sp->fts_pathlen);
+	p = recallocarray(sp->fts_path, sp->fts_pathlen,
+	    sp->fts_pathlen + more, 1);
 	if (p == NULL) {
 		free(sp->fts_path);
 		sp->fts_path = NULL;
 		return (1);
 	}
+	sp->fts_pathlen += more;
 	sp->fts_path = p;
 	return (0);
 }
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


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

only message in thread, other threads:[~2020-06-14 23:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-14 23:09 mandoc: merge rev 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).