diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2017-02-01 20:21:20 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2017-02-01 20:21:20 +0000 |
commit | c4a3a209edcc1d79c720ff1e7329c064447b5a02 (patch) | |
tree | 7648481bc9708c51eba4b609d2da7870beff4445 /usr.bin | |
parent | 1c5ed89c85c2796659f005d0496aa476e218fca1 (diff) |
Add a missing sizeof(*lines) factor to previous commit to ensure we zero
out enough of the lines array. Problem found with malloc's 'J' option.
ok martijn
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tail/read.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/tail/read.c b/usr.bin/tail/read.c index f08030fea66..8a47ddd01ce 100644 --- a/usr.bin/tail/read.c +++ b/usr.bin/tail/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.18 2017/02/01 16:21:12 martijn Exp $ */ +/* $OpenBSD: read.c,v 1.19 2017/02/01 20:21:19 tb Exp $ */ /* $NetBSD: read.c,v 1.4 1994/11/23 07:42:07 jtc Exp $ */ /*- @@ -169,7 +169,8 @@ lines(struct tailfile *tf, off_t off) lines = reallocarray(lines, nlineno, sizeof(*lines)); if (lines == NULL) err(1, NULL); - bzero(lines + recno, nlineno - lineno); + bzero(lines + recno, + (nlineno - lineno) * sizeof(*lines)); lineno = nlineno; } if (ch == '\n') { |