summaryrefslogtreecommitdiff
path: root/sshbuf.c
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2022-10-04 15:10:40 +0000
committerEd Maste <emaste@FreeBSD.org>2022-10-04 15:10:40 +0000
commit56fae06595918644df9cfd2f285777195c8d29b8 (patch)
tree3e8cd4c826b10ec878a70c5e4daabe584142e73f /sshbuf.c
parent7f9f5c27f6f623a2081f2b436692418fd962b903 (diff)
Diffstat (limited to 'sshbuf.c')
-rw-r--r--sshbuf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sshbuf.c b/sshbuf.c
index 368ba7980b75..d5757b7264ed 100644
--- a/sshbuf.c
+++ b/sshbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshbuf.c,v 1.15 2020/02/26 13:40:09 jsg Exp $ */
+/* $OpenBSD: sshbuf.c,v 1.18 2022/05/25 06:03:44 djm Exp $ */
/*
* Copyright (c) 2011 Damien Miller
*
@@ -109,6 +109,8 @@ sshbuf_set_parent(struct sshbuf *child, struct sshbuf *parent)
if ((r = sshbuf_check_sanity(child)) != 0 ||
(r = sshbuf_check_sanity(parent)) != 0)
return r;
+ if (child->parent != NULL && child->parent != parent)
+ return SSH_ERR_INTERNAL_ERROR;
child->parent = parent;
child->parent->refcount++;
return 0;
@@ -177,7 +179,8 @@ sshbuf_reset(struct sshbuf *buf)
buf->off = buf->size;
return;
}
- (void) sshbuf_check_sanity(buf);
+ if (sshbuf_check_sanity(buf) != 0)
+ return;
buf->off = buf->size = 0;
if (buf->alloc != SSHBUF_SIZE_INIT) {
if ((d = recallocarray(buf->d, buf->alloc, SSHBUF_SIZE_INIT,
@@ -186,7 +189,7 @@ sshbuf_reset(struct sshbuf *buf)
buf->alloc = SSHBUF_SIZE_INIT;
}
}
- explicit_bzero(buf->d, SSHBUF_SIZE_INIT);
+ explicit_bzero(buf->d, buf->alloc);
}
size_t