summaryrefslogtreecommitdiff
path: root/sshbuf.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2022-12-02 04:40:27 +0000
committerDarren Tucker <dtucker@dtucker.net>2022-12-04 22:39:42 +1100
commit3cec15543010bc8d6997d896b1717a650afb7e92 (patch)
tree40e6df8bfcd0e0cad61ad894b7ffe16c14c0be34 /sshbuf.c
parent5796bf8ca9535f9fa7d01829a540d2550e05c860 (diff)
downloadopenssh-git-3cec15543010bc8d6997d896b1717a650afb7e92.tar.gz
upstream: make struct sshbuf private
and remove an unused field; ok dtucker OpenBSD-Commit-ID: c7a3d77c0b8c153d463398606a8d57569186a0c3
Diffstat (limited to 'sshbuf.c')
-rw-r--r--sshbuf.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/sshbuf.c b/sshbuf.c
index d5757b72..d7f4e4ab 100644
--- a/sshbuf.c
+++ b/sshbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshbuf.c,v 1.18 2022/05/25 06:03:44 djm Exp $ */
+/* $OpenBSD: sshbuf.c,v 1.19 2022/12/02 04:40:27 djm Exp $ */
/*
* Copyright (c) 2011 Damien Miller
*
@@ -15,7 +15,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define SSHBUF_INTERNAL
#include "includes.h"
#include <sys/types.h>
@@ -25,9 +24,33 @@
#include <string.h>
#include "ssherr.h"
+#define SSHBUF_INTERNAL
#include "sshbuf.h"
#include "misc.h"
+#ifdef SSHBUF_DEBUG
+# define SSHBUF_TELL(what) do { \
+ printf("%s:%d %s: %s size %zu alloc %zu off %zu max %zu\n", \
+ __FILE__, __LINE__, __func__, what, \
+ buf->size, buf->alloc, buf->off, buf->max_size); \
+ fflush(stdout); \
+ } while (0)
+#else
+# define SSHBUF_TELL(what)
+#endif
+
+struct sshbuf {
+ u_char *d; /* Data */
+ const u_char *cd; /* Const data */
+ size_t off; /* First available byte is buf->d + buf->off */
+ size_t size; /* Last byte is buf->d + buf->size - 1 */
+ size_t max_size; /* Maximum size of buffer */
+ size_t alloc; /* Total bytes allocated to buf->d */
+ int readonly; /* Refers to external, const data */
+ u_int refcount; /* Tracks self and number of child buffers */
+ struct sshbuf *parent; /* If child, pointer to parent */
+};
+
static inline int
sshbuf_check_sanity(const struct sshbuf *buf)
{