diff options
author | 2017-03-17 15:14:40 +0000 | |
---|---|---|
committer | 2017-03-17 15:14:40 +0000 | |
commit | 10f4ce4cb041f2d65a07182678264bee0fb4eb20 (patch) | |
tree | 6e0ea9a4e422c79c6e8d9c56f201e72befd0914e /lib | |
parent | Be more strict on all route iterations, lets always make sure that we (diff) | |
download | wireguard-openbsd-10f4ce4cb041f2d65a07182678264bee0fb4eb20.tar.xz wireguard-openbsd-10f4ce4cb041f2d65a07182678264bee0fb4eb20.zip |
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 'lib')
-rw-r--r-- | lib/libc/gen/fts.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index ad4fb0423f9..98b3a0a390d 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fts.c,v 1.57 2017/02/15 15:58:40 schwarze Exp $ */ +/* $OpenBSD: fts.c,v 1.58 2017/03/17 15:14:40 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -881,14 +881,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) @@ -963,13 +963,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); } |