[Openvpn-devel,1/3] dco: properly re-initialize dco_del_peer_reason

Message ID 20230103202330.1835-1-a@unstable.cc
State Accepted
Headers show
Series [Openvpn-devel,1/3] dco: properly re-initialize dco_del_peer_reason | expand

Commit Message

Antonio Quartulli Jan. 3, 2023, 8:23 p.m. UTC
After processing a message, all fields of the dco object should be
re-initialized so that future processings are not affected by stale
values.

This includes dco_del_peer_reason.

Since its values can start at 0, re-initialize it with -1.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
 src/openvpn/multi.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Arne Schwabe Jan. 6, 2023, 2:51 p.m. UTC | #1
Am 03.01.23 um 21:23 schrieb Antonio Quartulli:
> After processing a message, all fields of the dco object should be
> re-initialized so that future processings are not affected by stale
> values.
> 
> This includes dco_del_peer_reason.
> 
> Since its values can start at 0, re-initialize it with -1.

Acked-By: Arne Schwabe <arne@rfc2549.org>

The place we do the reinitialisation is weird but for now just fix it.

ARne
Gert Doering Jan. 7, 2023, 5:01 p.m. UTC | #2
I've done a bit of stare-at-code, and it's nicely trivial :-) - but let
me repeat what I said on IRC, better coding style would be to do proper
initialization *before* calling dco_do_read(), not as an afterthought
at the end of the function (which also breaks "early return").

I have not tested this patch on its own (just compile-tested), as it's
trivial enough and has an ACK already.

For now this is fine, but we should come back here.

Your patch has been applied to the master branch.

commit e9889016fb7269d025a2dbba5f7079ee87e39520 (master)
commit aaccf88431eb146231a600971227a8a6c395b349 (release/2.6)
Author: Antonio Quartulli
Date:   Tue Jan 3 21:23:28 2023 +0100

     dco: properly re-initialize dco_del_peer_reason

     Signed-off-by: Antonio Quartulli <a@unstable.cc>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20230103202330.1835-1-a@unstable.cc>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25881.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 3658e1d5..27676de5 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -3301,6 +3301,7 @@  multi_process_incoming_dco(struct multi_context *m)
 
     dco->dco_message_type = 0;
     dco->dco_message_peer_id = -1;
+    dco->dco_del_peer_reason = -1;
     dco->dco_read_bytes = 0;
     dco->dco_write_bytes = 0;
     return ret > 0;