diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-08-28 10:47:58 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-08-28 10:47:58 +0000 |
| commit | d46065df2d60bfbd08939733bd79b2a440d6fbc8 (patch) | |
| tree | 720921fc9471de3c67f5b8dc1404c8f6c6a02cb1 /sshbuf.c | |
| parent | 3d0e42005d3bf786341ab96cfa1788bc601faa12 (diff) | |
Diffstat (limited to 'sshbuf.c')
| -rw-r--r-- | sshbuf.c | 22 |
1 files changed, 2 insertions, 20 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: sshbuf.c,v 1.11 2017/06/01 06:58:25 djm Exp $ */ +/* $OpenBSD: sshbuf.c,v 1.12 2018/07/09 21:56:06 markus Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -36,7 +36,6 @@ sshbuf_check_sanity(const struct sshbuf *buf) (!buf->readonly && buf->d != buf->cd) || buf->refcount < 1 || buf->refcount > SSHBUF_REFS_MAX || buf->cd == NULL || - (buf->dont_free && (buf->readonly || buf->parent != NULL)) || buf->max_size > SSHBUF_SIZE_MAX || buf->alloc > buf->max_size || buf->size > buf->alloc || @@ -132,23 +131,8 @@ sshbuf_fromb(struct sshbuf *buf) } void -sshbuf_init(struct sshbuf *ret) -{ - explicit_bzero(ret, sizeof(*ret)); - ret->alloc = SSHBUF_SIZE_INIT; - ret->max_size = SSHBUF_SIZE_MAX; - ret->readonly = 0; - ret->dont_free = 1; - ret->refcount = 1; - if ((ret->cd = ret->d = calloc(1, ret->alloc)) == NULL) - ret->alloc = 0; -} - -void sshbuf_free(struct sshbuf *buf) { - int dont_free = 0; - if (buf == NULL) return; /* @@ -173,14 +157,12 @@ sshbuf_free(struct sshbuf *buf) buf->refcount--; if (buf->refcount > 0) return; - dont_free = buf->dont_free; if (!buf->readonly) { explicit_bzero(buf->d, buf->alloc); free(buf->d); } explicit_bzero(buf, sizeof(*buf)); - if (!dont_free) - free(buf); + free(buf); } void |
