From 3733d24a9066bdd3e038d642a62cf642abd0b0bf Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 30 Mar 2017 21:26:17 +0200 Subject: Fix -Werror=format-security issues --- CMakeLists.txt | 22 ++++++++++++++-------- configure | 8 ++++++-- libdino/src/application.vala | 2 +- libdino/src/plugin/loader.vala | 2 +- plugins/gpgme-vala/vapi/gpgme.vapi | 2 +- .../vapi/signal-protocol-public.vapi | 2 +- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e367591..bac892fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,25 +45,31 @@ set(PLUGIN_INSTALL LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} RUNTIME DESTINATION include(CheckCCompilerFlag) macro(AddCFlagIfSupported flag) - CHECK_C_COMPILER_FLAG(${flag} COMPILER_SUPPORTS${flag}) - if(${COMPILER_SUPPORTS${flag}}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") - endif() + string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag}) + CHECK_C_COMPILER_FLAG(${flag} COMPILER_SUPPORTS${flag_name}) + if(${COMPILER_SUPPORTS${flag_name}}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif() endmacro() macro(AddValaCFlagIfSupported flag) - CHECK_C_COMPILER_FLAG(${flag} COMPILER_SUPPORTS${flag}) - if(${COMPILER_SUPPORTS${flag}}) - set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}") - endif() + string(REGEX REPLACE "[^a-z^A-Z^_^0-9]+" "_" flag_name ${flag}) + CHECK_C_COMPILER_FLAG(${flag} COMPILER_SUPPORTS${flag_name}) + if(${COMPILER_SUPPORTS${flag_name}}) + set(VALA_CFLAGS "${VALA_CFLAGS} ${flag}") + endif() endmacro() if("Ninja" STREQUAL ${CMAKE_GENERATOR}) AddCFlagIfSupported(-fdiagnostics-color COMPILER_SUPPORTS_fdiagnistics-color) endif() +AddCFlagIfSupported(-Wall) +AddCFlagIfSupported(-Werror=format-security) + AddValaCFlagIfSupported(-Wno-deprecated-declarations) AddValaCFlagIfSupported(-Wno-incompatible-pointer-types) +AddValaCFlagIfSupported(-Wno-pointer-sign) AddValaCFlagIfSupported(-Wno-int-conversion) AddValaCFlagIfSupported(-Wno-discarded-qualifiers) AddValaCFlagIfSupported(-Wno-unused-but-set-variable) diff --git a/configure b/configure index 95d161eb..22673bc4 100755 --- a/configure +++ b/configure @@ -151,13 +151,17 @@ else exit 5 fi res=$(git clone "$url" "$path" 2>&1) - if ! [ $? -eq 0 ] || ! [ -x $git ]; then + if ! [ $? -eq 0 ] || ! [ -d $path ]; then echo "Failed retrieving missing files: $res" exit 5 fi if [[ "$branch" != "" ]]; then pushd "$path" > /dev/null - git checkout "$branch" 2>/dev/null + res=$(git checkout "$branch" 2>&1) + if ! [ $? -eq 0 ]; then + echo "Failed retrieving missing files: $res" + exit 5 + fi popd > /dev/null fi echo "Submodule path '$path': checked out '$branch' (via git clone)" diff --git a/libdino/src/application.vala b/libdino/src/application.vala index 9cabf0f4..99cef929 100644 --- a/libdino/src/application.vala +++ b/libdino/src/application.vala @@ -10,7 +10,7 @@ public class Dino.Application : Gtk.Application { public Application() throws Error { if (DirUtils.create_with_parents(get_storage_dir(), 0700) == -1) { - throw new Error(-1, 0, @"Could not create storage dir \"$(get_storage_dir())\": $(FileUtils.error_from_errno(errno))"); + throw new Error(-1, 0, "Could not create storage dir \"%s\": %s", get_storage_dir(), FileUtils.error_from_errno(errno).to_string()); } // FIXME: Legacy import diff --git a/libdino/src/plugin/loader.vala b/libdino/src/plugin/loader.vala index 8c633ef1..7497311d 100644 --- a/libdino/src/plugin/loader.vala +++ b/libdino/src/plugin/loader.vala @@ -59,7 +59,7 @@ public class Loader : Object { if (module != null) break; } if (module == null) { - throw new Error (-1, 1, Module.error ().replace(path, name)); + throw new Error (-1, 1, "%s", Module.error ().replace(path, name)); } void* function; diff --git a/plugins/gpgme-vala/vapi/gpgme.vapi b/plugins/gpgme-vala/vapi/gpgme.vapi index 48d11b8c..0b14185c 100644 --- a/plugins/gpgme-vala/vapi/gpgme.vapi +++ b/plugins/gpgme-vala/vapi/gpgme.vapi @@ -506,7 +506,7 @@ namespace GPG { private void throw_if_error(GPGError.Error error) throws GLib.Error { if (error.code != GPGError.ErrorCode.NO_ERROR) { - throw new GLib.Error(-1, error.code, error.to_string()); + throw new GLib.Error(-1, error.code, "%s", error.to_string()); } } } diff --git a/plugins/signal-protocol/vapi/signal-protocol-public.vapi b/plugins/signal-protocol/vapi/signal-protocol-public.vapi index d0208c6c..f879c583 100644 --- a/plugins/signal-protocol/vapi/signal-protocol-public.vapi +++ b/plugins/signal-protocol/vapi/signal-protocol-public.vapi @@ -38,7 +38,7 @@ namespace Signal { [CCode (cname = "signal_throw_gerror_by_code_", cheader_filename = "signal_protocol.h")] private int throw_by_code(int code, string? message = null) throws GLib.Error { if (code < 0 && code > MIN_ERROR_CODE) { - throw new GLib.Error(-1, code, @"$(message ?? "Signal error"): $((ErrorCode)code)"); + throw new GLib.Error(-1, code, "%s: %s", message ?? "Signal error", ((ErrorCode)code).to_string()); } return code; } -- cgit v1.2.3-70-g09d2