Fix -Werror=format-security issues

This commit is contained in:
Marvin W 2017-03-30 21:26:17 +02:00
parent e910b39751
commit 3733d24a90
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
6 changed files with 24 additions and 14 deletions

View file

@ -45,15 +45,17 @@ 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}})
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}})
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()
@ -62,8 +64,12 @@ 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)

8
configure vendored
View file

@ -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)"

View file

@ -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

View file

@ -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;

View file

@ -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());
}
}
}

View file

@ -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;
}