Silence warning about format string in check_ca_required
PATCH 1/1 Silence warning about format string in check_ca_required
clang does not like if the format argument of printf like function is not a string literal:
warning: format string is not a string literal (potentially insecure)
Use "%s" as string literal to silence the warning.
--- src/openvpn/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/options.c +1 -1
@@ -2077,7 +2077,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.32.0
Hi,
Quoted 17 lines · Arne Schwabe
clang does not like if the format argument of printf like function is not a string literal:
warning: format string is not a string literal (potentially insecure)
Use "%s" as string literal to silence the warning.
Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/openvpn/options.c +0
-0
src/openvpn/options.c check_ca_required(const struct options *options) · line 2080
Quoted 5 lines
src/openvpn/options.c +1
-1@@ -2077,7 +2077,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);
Imho this warning is a borderline one.
Rather than using %s as clang suggests, I am more in favor of the following:
src/openvpn/options.c +1 -1
@@ -2069,7 +2069,7 @@ check_ca_required(const struct options *options)return ; } -const char * str ="You must define CA file (--ca)" +const char *const str ="You must define CA file (--ca)" #ifndef ENABLE_CRYPTO_MBEDTLS" or CA path (--capath)" #endif
Passing "%s" just to make clang happy looks weird to me.
Regards,
Signature · 1 line
Antonio Quartulli
Hi
Quoted 7 lines · Arne Schwabe
clang does not like if the format argument of printf like function is not a string literal:
warning: format string is not a string literal (potentially insecure)
Use "%s" as string literal to silence the warning.
Format string is often not a string literal -- we have many other such usages in the source, though probably none without a third argument. grep for fmt, for example. Here str is a const char *, what more do they want? Would const char * const str work?
Selva
PATCH v2 1/1 Silence warning about format string in check_ca_required
In reply to Arne SchwabeFrom: Arne Schwabe <[email protected]...>
clang does not like if the format argument of printf like function is not a string literal (or constant):
warning: format string is not a string literal (potentially insecure)
Make the format string constant to silence the warning.
---
Changes from v1:
* use const string instead of introducing "%s".
@Arne I anticipated this change because I "assumed" you would be ok with it (patch is still yours), but feel free to comment of course.
src/openvpn/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/options.c +1 -1
@@ -2069,7 +2069,7 @@ check_ca_required(const struct options *options)return ; } -const char * str ="You must define CA file (--ca)" +const char *const str ="You must define CA file (--ca)" #ifndef ENABLE_CRYPTO_MBEDTLS" or CA path (--capath)" #endif
Signature · 1 line
2.31.1
Hi
Quoted 37 lines · Antonio Quartulli
From: Arne Schwabe <[email protected]...>
clang does not like if the format argument of printf like function is not a string literal (or constant):
warning: format string is not a string literal (potentially insecure)
Make the format string constant to silence the warning.
Signed-off-by Arne Schwabe <[email protected]...>Signed-off-by Antonio Quartulli <[email protected]...>---
Changes from v1:
* use const string instead of introducing "%s".@Arne I anticipated this change because I "assumed" you would be ok with it (patch is still yours), but feel free to comment of course.
src/openvpn/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/openvpn/options.c +1
-2@@ -2069,7 +2069,7 @@ check_ca_required(const struct options *options)return ; } -const char * str ="You must define CA file (--ca)" +const char *const str ="You must define CA file (--ca)" #ifndef ENABLE_CRYPTO_MBEDTLS" or CA path (--capath)" #endif --
Quoted 2 lines
2.31.1
Changes from v1:
Quoted 6 lines
* use const string instead of introducing "%s".
@Arne I anticipated this change because I "assumed" you would be ok with it (patch is still yours), but feel free to comment of course.
In that spirit, assuming Antonio would have acked this had it been submitted by Arne, I'm ready to ack this on his behalf..
Earnestly hoping these lines don't show up again in a patch for a very long time to come..
Selva
Your patch has been applied to the master branch.
And I side with Selva "I do not want to see more of these lines in a patch for a very long time" :-)
commit d2e5412aa48e028c07bc7a3a9447593b711a9e0c
Author: Arne Schwabe Date: Wed Jun 9 08:15:32 2021 +0200
Silence warning about format string in check_ca_required
Signed-off-by: Arne Schwabe <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Selva Nair <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg22519.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering