fix -Werror build: logging.c: always use literal with snprintf A recent commit added an snprintf that passes a pointer to a literal directly to snprintf. Since passing pointers to printf formats is a vulnerability in case user supplied data may be passed in the format, modern compilers warn against that, which breaks our -Werror builds. Even though this is just a pointer to a literal, it needs to be an actual literal to make compilers happy.
Use printf("%s", c) instead of printf(c). Note that our current build slave's gcc does not enforce that yet, while newer compilers do. logging.c:338:4: warning: format not a string literal and no format arguments [-Wformat-security] ret = snprintf(buf + offset, rem, c_subsys); Change-Id: Ifa4eb8a9fab66dcd987986065351b4a06421f1ec --- M src/logging.c 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/45/5845/2 diff --git a/src/logging.c b/src/logging.c index a6aa7eb..9b37bf5 100644 --- a/src/logging.c +++ b/src/logging.c @@ -335,7 +335,7 @@ if (target->use_color) { c_subsys = color(subsys); if (c_subsys) { - ret = snprintf(buf + offset, rem, c_subsys); + ret = snprintf(buf + offset, rem, "%s", c_subsys); if (ret < 0) goto err; OSMO_SNPRINTF_RET(ret, rem, offset, len); -- To view, visit https://gerrit.osmocom.org/5845 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ifa4eb8a9fab66dcd987986065351b4a06421f1ec Gerrit-PatchSet: 2 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder