summaryrefslogtreecommitdiffstats
path: root/bitmap.c
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2017-05-31 11:15:42 +0200
committerDamien Miller <djm@mindrot.org>2017-06-01 06:55:22 +0200
commit9e509d4ec97cb3d71696f1a2f1fdad254cbbce11 (patch)
tree8f33ae8fa9bcfa0d9c80d0e0f1555a814a844bc1 /bitmap.c
parentupstream commit (diff)
downloadopenssh-9e509d4ec97cb3d71696f1a2f1fdad254cbbce11.tar.xz
openssh-9e509d4ec97cb3d71696f1a2f1fdad254cbbce11.zip
upstream commit
Switch to recallocarray() for a few operations. Both growth and shrinkage are handled safely, and there also is no need for preallocation dances. Future changes in this area will be less error prone. Review and one bug found by markus Upstream-ID: 822d664d6a5a1d10eccb23acdd53578a679d5065
Diffstat (limited to 'bitmap.c')
-rw-r--r--bitmap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/bitmap.c b/bitmap.c
index 3d7aa1379..71f87ec54 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -87,7 +87,7 @@ reserve(struct bitmap *b, u_int n)
return -1; /* invalid */
nlen = (n / BITMAP_BITS) + 1;
if (b->len < nlen) {
- if ((tmp = reallocarray(b->d, nlen, BITMAP_BYTES)) == NULL)
+ if ((tmp = recallocarray(b->d, b->len, nlen, BITMAP_BYTES)) == NULL)
return -1;
b->d = tmp;
memset(b->d + b->len, 0, (nlen - b->len) * BITMAP_BYTES);