summaryrefslogtreecommitdiff
path: root/bitmap.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2017-10-04 11:23:58 +0100
committerColin Watson <cjwatson@debian.org>2017-10-04 11:23:58 +0100
commit62f54f20bf351468e0124f63cc2902ee40d9b0e9 (patch)
tree3e090f2711b94ca5029d3fa3e8047b1ed1448b1f /bitmap.c
parent6fabaf6fd9b07cc8bc6a17c9c4a5b76849cfc874 (diff)
parent66bf74a92131b7effe49fb0eefe5225151869dc5 (diff)
Import openssh_7.6p1.orig.tar.gz
Diffstat (limited to 'bitmap.c')
-rw-r--r--bitmap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/bitmap.c b/bitmap.c
index f95032250..5089b0407 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -53,8 +53,9 @@ void
53bitmap_free(struct bitmap *b) 53bitmap_free(struct bitmap *b)
54{ 54{
55 if (b != NULL && b->d != NULL) { 55 if (b != NULL && b->d != NULL) {
56 explicit_bzero(b->d, b->len); 56 bitmap_zero(b);
57 free(b->d); 57 free(b->d);
58 b->d = NULL;
58 } 59 }
59 free(b); 60 free(b);
60} 61}
@@ -86,10 +87,10 @@ reserve(struct bitmap *b, u_int n)
86 return -1; /* invalid */ 87 return -1; /* invalid */
87 nlen = (n / BITMAP_BITS) + 1; 88 nlen = (n / BITMAP_BITS) + 1;
88 if (b->len < nlen) { 89 if (b->len < nlen) {
89 if ((tmp = reallocarray(b->d, nlen, BITMAP_BYTES)) == NULL) 90 if ((tmp = recallocarray(b->d, b->len,
91 nlen, BITMAP_BYTES)) == NULL)
90 return -1; 92 return -1;
91 b->d = tmp; 93 b->d = tmp;
92 memset(b->d + b->len, 0, (nlen - b->len) * BITMAP_BYTES);
93 b->len = nlen; 94 b->len = nlen;
94 } 95 }
95 return 0; 96 return 0;
@@ -188,7 +189,7 @@ bitmap_from_string(struct bitmap *b, const void *p, size_t l)
188{ 189{
189 int r; 190 int r;
190 size_t i, offset, shift; 191 size_t i, offset, shift;
191 u_char *s = (u_char *)p; 192 const u_char *s = (const u_char *)p;
192 193
193 if (l > BITMAP_MAX / 8) 194 if (l > BITMAP_MAX / 8)
194 return -1; 195 return -1;