[Openvpn-devel,v8] comp: Make sure comp flags are treated as unsigned

Message ID 20250826185007.22157-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v8] comp: Make sure comp flags are treated as unsigned | expand

Commit Message

Gert Doering Aug. 26, 2025, 6:50 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

compress_options.flags is already unsigned. Make sure
the individual flags are as well to avoid spurious
conversion warnings.

Change-Id: I6a0d352a039a0936cb9bbedf6168cd6eecd053ea
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
---

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/+/1102
This mail reflects revision 8 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <arne-openvpn@rfc2549.org>

Comments

Gert Doering Aug. 27, 2025, 9:13 a.m. UTC | #1
Stared a bit at the change - this is all values well within the range
of all integers involved (max value is 1<<7) so the impact *should* be
zero, and BB confirms that everything still works - minus a few integer
conversion warnings...

Your patch has been applied to the master branch.

commit 2f6467f7db8273e8094656e46a6ae60cbc1d0af9
Author: Frank Lichtenheld
Date:   Tue Aug 26 20:50:00 2025 +0200

     comp: Make sure comp flags are treated as unsigned

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
     Message-Id: <20250826185007.22157-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32689.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/comp.h b/src/openvpn/comp.h
index 265e15d..0354896 100644
--- a/src/openvpn/comp.h
+++ b/src/openvpn/comp.h
@@ -32,23 +32,23 @@ 
 
 /* Compression flags */
 /* Removed
- #define COMP_F_ADAPTIVE             (1<<0) / * COMP_ALG_LZO only * /
- #define COMP_F_ALLOW_COMPRESS       (1<<1) / * not only incoming is compressed but also outgoing *
+ #define COMP_F_ADAPTIVE             (1u<<0) / * COMP_ALG_LZO only * /
+ #define COMP_F_ALLOW_COMPRESS       (1u<<1) / * not only incoming is compressed but also outgoing *
  /
  */
 /** initial command byte is swapped with last byte in buffer to preserve payload alignment */
-#define COMP_F_SWAP                 (1 << 2)
+#define COMP_F_SWAP                 (1u << 2)
 /** tell server that we only support compression stubs */
-#define COMP_F_ADVERTISE_STUBS_ONLY (1 << 3)
+#define COMP_F_ADVERTISE_STUBS_ONLY (1u << 3)
 /** Only accept stub compression, even with COMP_F_ADVERTISE_STUBS_ONLY
  * we still accept other compressions to be pushed */
-#define COMP_F_ALLOW_STUB_ONLY      (1 << 4)
+#define COMP_F_ALLOW_STUB_ONLY      (1u << 4)
 /** push stub-v2 or comp-lzo no when we see a client with comp-lzo in occ */
-#define COMP_F_MIGRATE              (1 << 5)
+#define COMP_F_MIGRATE              (1u << 5)
 /** Compression was explicitly set to allow asymetric compression */
-#define COMP_F_ALLOW_ASYM           (1 << 6)
+#define COMP_F_ALLOW_ASYM           (1u << 6)
 /** Do not allow compression framing (breaks DCO) */
-#define COMP_F_ALLOW_NOCOMP_ONLY    (1 << 7)
+#define COMP_F_ALLOW_NOCOMP_ONLY    (1u << 7)
 
 /* algorithms */
 #define COMP_ALG_UNDEF  0