Skip to contentSkip to conversation

options.c: fix format security error when compiling without optimization

PATCH In review Frank Lichtenheld 3 participants 3 messages Dec 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 options.c: fix format security error when compiling without optimization

error: format not a string literal and no format arguments [-Werror=format-security]
2309 | msg(M_USAGE, str);

Found by accident, since it only happens without optimization. Seems the compiler can figure out that this is harmless when thinking a bit harder about it. Fix anyway.

---
 src/openvpn/options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/options.c +1 -1
index e454b2ac..7395019e 100644
@@ -2306,7 +2306,7 @@ check_ca_required(const struct options *options)
                             " or CA path (--capath)"
 #endif
                             " and/or peer fingerprint verification (--peer-fingerprint)";
-    msg(M_USAGE, str);
+    msg(M_USAGE, "%s", str);
 }
 
 static void
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw

Am 28.12.22 um 12:07 schrieb Frank Lichtenheld:

Quoted 17 lines

error: format not a string literal and no format arguments [-Werror=format-security]
2309 | msg(M_USAGE, str);

Found by accident, since it only happens without optimization. Seems the compiler can figure out that this is harmless when thinking a bit harder about it. Fix anyway.

---
  src/openvpn/options.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/options.c +0 -0
index e454b2ac..7395019e 100644

src/openvpn/options.c check_ca_required(const struct options *options) · line 2312

Quoted 8 lines
src/openvpn/options.c +1 -1
@@ -2306,7 +2306,7 @@ check_ca_required(const struct options *options)
                              " or CA path (--capath)"
  #endif
                              " and/or peer fingerprint verification (--peer-fingerprint)";
-    msg(M_USAGE, str);
+    msg(M_USAGE, "%s", str);
  }
 
  static void
#2 lore raw
In reply to Frank Lichtenheld

Funny code section... why introduce a variable, when it could have called msg() directly. But anyway.

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

commit 24fc4ce25432a42170477f21133bb0f25a8a860d (master) commit cdcaebcbdf31cb629e54147d476e6fb9921f7999 (release/2.6)

Author: Frank Lichtenheld
Date:   Wed Dec 28 12:07:52 2022 +0100
     options.c: fix format security error when compiling without optimization

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg25848.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering