[Openvpn-devel,v1] win: Fix nrpt_dnssec flag handling

Message ID 20260405102209.31528-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] win: Fix nrpt_dnssec flag handling | expand

Commit Message

Gert Doering April 5, 2026, 10:22 a.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

By default the first enum value is 0.
But we check whether we set the flag by doing
BOOL dnssec = (msg->flags & nrpt_dnssec) != 0;
This can't ever be true.

Found by cppcheck.

Change-Id: Iff5be978817bfc0cd4d78818e7be7b90bad71f3c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1606
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1606
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering April 5, 2026, 2:32 p.m. UTC | #1
Good catch, and obvious bug... and use of enum for a "bit map style"
flags thing was not really a good approach in the first place.  Now it
will work ("any value *but* 0 will work"), but when this is extended
to cover "more than 1 flag", going away from the enum would be a good
plan.  For the bug fix, a minimal approach is suitable.

I have not tested this beyond "does it compile on Ubuntu/MinGW", but
it looks very obviously correct ("stare at 'git grep nrpt_dnssec'").

Your patch has been applied to the master and release/2.7 branch.

commit 08a19843a184c6cb8850ac9e6bf7ce0cd4d15d37 (master)
commit 2aaa5e4d7c5bae35d7befdebeed065c634292151 (release/2.7)
Author: Frank Lichtenheld
Date:   Sun Apr 5 12:22:04 2026 +0200

     win: Fix nrpt_dnssec flag handling

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1606
     Message-Id: <20260405102209.31528-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36487.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/include/openvpn-msg.h b/include/openvpn-msg.h
index bef20cf..ca3267e 100644
--- a/include/openvpn-msg.h
+++ b/include/openvpn-msg.h
@@ -110,7 +110,7 @@ 
 
 typedef enum
 {
-    nrpt_dnssec
+    nrpt_dnssec = 1 << 0,
 } nrpt_flags_t;
 
 #define NRPT_ADDR_NUM  8  /* Max. number of addresses */