[Openvpn-devel,XS] Change in openvpn[master]: mudp.c: keep offset value when reset buffer

Message ID 241103e957af68f399f7e150e8f6c8674c67d951-HTML@gerrit.openvpn.net
State New
Headers show
Series [Openvpn-devel,XS] Change in openvpn[master]: mudp.c: keep offset value when reset buffer | expand

Commit Message

stipa (Code Review) Nov. 21, 2024, 6:07 p.m. UTC
Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/814?usp=email

to review the following change.


Change subject: mudp.c: keep offset value when reset buffer
......................................................................

mudp.c: keep offset value when reset buffer

dco-win requires control packets to be prepended
with sockaddr. For that, an offset value in buffer
must be kept. Doing it always doesn't harm and makes
code cleaner compared to adding "if (dco_win_server)"
condition.

Change-Id: I145573555aaace5e94774b5f977d032d3747ed72
Signed-off-by: Lev Stipakov <lev@openvpn.net>
---
M src/openvpn/mudp.c
1 file changed, 3 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/14/814/1

Patch

diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
index 5fbd7b0..d8e3d69 100644
--- a/src/openvpn/mudp.c
+++ b/src/openvpn/mudp.c
@@ -54,7 +54,9 @@ 
 
     struct context *c = &m->top;
 
-    buf_reset_len(&c->c2.buffers->aux_buf);
+    /* dco-win server requres prepend with sockaddr, so preserve offset */
+    buf_init(&c->c2.buffers->aux_buf, buf.offset);
+
     buf_copy(&c->c2.buffers->aux_buf, &buf);
     m->hmac_reply = c->c2.buffers->aux_buf;
     m->hmac_reply_dest = &m->top.c2.from;