From: "flichtenheld (Code Review)" Date: Wed, 6 May 2026 21:21:22 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <4c41e1e0cd0bd069afb092bda40719a6d8eb3b27-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="//9d/XWzTbk="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: buffer: Fix some issues with -DVERIFY_ALIGNMENT List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --//9d/XWzTbk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1666?usp=3Demail to review the following change. 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 --- M src/openvpn/buffer.c 1 file changed, 10 insertions(+), 5 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1666/1 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 =3D (int)size; - buf.offset =3D 0; - buf.len =3D 0; #ifdef DMALLOC buf.data =3D 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 =3D (int)size; - buf.offset =3D 0; - buf.len =3D 0; #ifdef DMALLOC buf.data =3D (uint8_t *)gc_malloc_debug(size, false, gc, file, line); #else @@ -120,6 +119,10 @@ ret.capacity =3D buf->capacity; ret.offset =3D buf->offset; ret.len =3D buf->len; +#ifdef BUF_INIT_TRACKING + ret.debug_file =3D buf->debug_file; + ret.debug_line =3D buf->debug_line; +#endif #ifdef DMALLOC ret.data =3D (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 =3D D_ALIGN_DEBUG; - const unsigned int u =3D (unsigned int)BPTR(buf); + const uintptr_t u =3D (uintptr_t)BPTR(buf); if (u & (PAYLOAD_ALIGN - 1)) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1666?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I3ecb76d9022dcd7dae92eb5e9d62e5f018744883 Gerrit-Change-Number: 1666 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --//9d/XWzTbk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

buffer: Fix some issues with -DVERIFY_ALIGN=
MENT

- Fix some uninitalised fields due to BUF_INIT_TRACKING
(f= ound by cppcheck and the original reason for this
change).
- Fix &= quot;unused functions" if only BUF_INIT_TRACKING is
defined.
-= Fix conversion error

Change-Id: I3ecb76d9022dcd7dae92eb5e9d62e5f018= 744883
Signed-off-by: Frank Lichtenheld <frank@...2641...>
---<= br>M src/openvpn/buffer.c
1 file changed, 10 insertions(+), 5 deletions(= -)

git pull ssh://gerrit.openvpn.net:29418/openv=
pn refs/changes/66/1666/1
diff --git a/src/openvpn/buffer.c b/src/o=
penvpn/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.cap= acity =3D (int)size;
- = buf.offset =3D 0;
- = buf.len =3D 0;
#ifdef DMALLOC
buf.= data =3D 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 =3D (int)size;
- buf.offset =3D 0;
- buf.len =3D 0;
#ifdef = DMALLOC
buf.data =3D (uint8_t *)gc_malloc_debug(size, = false, gc, file, line);
#else
@@ -120,6 +1= 19,10 @@
ret.capacity =3D buf->capacity;
= ret.offset =3D buf->offset;
ret.len =3D = buf->len;
+#ifdef = BUF_INIT_TRACKING
+ = ret.debug_file =3D buf->debug_file;
+ ret.debug_line =3D buf->debug_line;
<= span style=3D"color: hsl(120, 100%, 40%);">+#endif

#ifdef = DMALLOC
ret.data =3D (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<= br> buf_debug_line(const struct buffer *buf)
{
@@ -151,6 +155,7 @@
{
retu= rn buf->debug_file;
}
+#endif

#else /* if= def BUF_INIT_TRACKING */

@@ -1152,7 +1157= ,7 @@
if (buf && buf->len)
= {
msglvl_t msglevel =3D D_ALIGN_DEBUG;=
- const unsigned int u= =3D (unsigned int)BPTR(buf);
+ const uintptr_t u =3D (uintptr_t)BPTR(buf);

if (u & (PAYLOAD_ALIGN - 1))
{

To view, visit change 1666= . To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3ecb76d9022dcd7dae92eb5e9d6= 2e5f018744883
Gerrit-Change-Number: 1666
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --//9d/XWzTbk=--