cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1666?usp=email )
Change subject: buffer: Fix some issues with -DVERIFY_ALIGNMENT ...................................................................... buffer: Fix some issues with -DVERIFY_ALIGNMENT - Fix some uninitalised fields due to BUF_INIT_TRACKING (found by cppcheck and the original reason for this change). - Fix "unused functions" if only BUF_INIT_TRACKING is defined. - Fix conversion error Change-Id: I3ecb76d9022dcd7dae92eb5e9d62e5f018744883 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1666 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg36901.html Signed-off-by: Gert Doering <[email protected]> --- M src/openvpn/buffer.c 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 71f3769..1e19137 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -64,14 +64,13 @@ #endif { struct buffer buf; + CLEAR(buf); if (!buf_size_valid(size)) { buf_size_error(size); } buf.capacity = (int)size; - buf.offset = 0; - buf.len = 0; #ifdef DMALLOC buf.data = openvpn_dmalloc(file, line, size); #else @@ -90,13 +89,13 @@ #endif { struct buffer buf; + CLEAR(buf); + if (!buf_size_valid(size)) { buf_size_error(size); } buf.capacity = (int)size; - buf.offset = 0; - buf.len = 0; #ifdef DMALLOC buf.data = (uint8_t *)gc_malloc_debug(size, false, gc, file, line); #else @@ -120,6 +119,10 @@ ret.capacity = buf->capacity; ret.offset = buf->offset; ret.len = buf->len; +#ifdef BUF_INIT_TRACKING + ret.debug_file = buf->debug_file; + ret.debug_line = buf->debug_line; +#endif #ifdef DMALLOC ret.data = (uint8_t *)openvpn_dmalloc(file, line, buf->capacity); #else @@ -140,6 +143,7 @@ return buf_init_dowork(buf, offset); } +#ifdef VERIFY_ALIGNMENT static inline int buf_debug_line(const struct buffer *buf) { @@ -151,6 +155,7 @@ { return buf->debug_file; } +#endif #else /* ifdef BUF_INIT_TRACKING */ @@ -1152,7 +1157,7 @@ if (buf && buf->len) { msglvl_t msglevel = D_ALIGN_DEBUG; - const unsigned int u = (unsigned int)BPTR(buf); + const uintptr_t u = (uintptr_t)BPTR(buf); if (u & (PAYLOAD_ALIGN - 1)) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1666?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I3ecb76d9022dcd7dae92eb5e9d62e5f018744883 Gerrit-Change-Number: 1666 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld <[email protected]> Gerrit-Reviewer: cron2 <[email protected]> Gerrit-Reviewer: plaisthos <[email protected]> Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
