From 60dd6e7e48b1b1e28c38dd2159aa725d56d79ce4 Mon Sep 17 00:00:00 2001 From: djm Date: Fri, 2 Dec 2022 04:40:27 +0000 Subject: [PATCH] make struct sshbuf private and remove an unused field; ok dtucker --- usr.bin/ssh/sshbuf.c | 25 ++++++++++++++++++++++++- usr.bin/ssh/sshbuf.h | 26 ++------------------------ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/usr.bin/ssh/sshbuf.c b/usr.bin/ssh/sshbuf.c index 415ebc3354e..b5cbfda846d 100644 --- a/usr.bin/ssh/sshbuf.c +++ b/usr.bin/ssh/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 * @@ -26,6 +26,29 @@ #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) { diff --git a/usr.bin/ssh/sshbuf.h b/usr.bin/ssh/sshbuf.h index 7e9b586f330..37c28a12767 100644 --- a/usr.bin/ssh/sshbuf.h +++ b/usr.bin/ssh/sshbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sshbuf.h,v 1.27 2022/05/25 06:03:44 djm Exp $ */ +/* $OpenBSD: sshbuf.h,v 1.28 2022/12/02 04:40:27 djm Exp $ */ /* * Copyright (c) 2011 Damien Miller * @@ -38,22 +38,7 @@ #define SSHBUF_MAX_BIGNUM (16384 / 8) /* Max bignum *bytes* */ #define SSHBUF_MAX_ECPOINT ((528 * 2 / 8) + 1) /* Max EC point *bytes* */ -/* - * NB. do not depend on the internals of this. It will be made opaque - * one day. - */ -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 */ - int dont_free; /* Kludge to support sshbuf_init */ - u_int refcount; /* Tracks self and number of child buffers */ - struct sshbuf *parent; /* If child, pointer to parent */ -}; +struct sshbuf; /* * Create a new sshbuf buffer. @@ -395,12 +380,6 @@ u_int sshbuf_refcount(const struct sshbuf *buf); # endif # 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) # define SSHBUF_DBG(x) do { \ printf("%s:%d %s: ", __FILE__, __LINE__, __func__); \ printf x; \ @@ -408,7 +387,6 @@ u_int sshbuf_refcount(const struct sshbuf *buf); fflush(stdout); \ } while (0) # else -# define SSHBUF_TELL(what) # define SSHBUF_DBG(x) # endif #endif /* SSHBUF_INTERNAL */ -- 2.20.1