diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2020-06-14 23:08:35 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2020-06-14 23:08:35 +0000 |
commit | bd0a544f0b4a0b27cceb27491da4eb567414c8ce (patch) | |
tree | 538b38f9b2d12ff8c425c6f5e948e9fd08609316 /compat_fts.c | |
parent | 77c0aeafdb196f1dfe90683bbff71a3d1cb5fbcf (diff) | |
download | mandoc-bd0a544f0b4a0b27cceb27491da4eb567414c8ce.tar.gz mandoc-bd0a544f0b4a0b27cceb27491da4eb567414c8ce.tar.zst mandoc-bd0a544f0b4a0b27cceb27491da4eb567414c8ce.zip |
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@
Diffstat (limited to 'compat_fts.c')
-rw-r--r-- | compat_fts.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compat_fts.c b/compat_fts.c index 0106923a..177d1c1f 100644 --- a/compat_fts.c +++ b/compat_fts.c @@ -6,8 +6,8 @@ int dummy; #else -/* $Id: compat_fts.c,v 1.15 2020/06/14 22:49:36 schwarze Exp $ */ -/* $OpenBSD: fts.c,v 1.56 2016/09/21 04:38:56 guenther Exp $ */ +/* $Id: compat_fts.c,v 1.16 2020/06/14 23:08:35 schwarze 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 nitems) 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); } |