diff --git a/CMakeLists.txt b/CMakeLists.txt index a2a0c94..dce806c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,16 +15,35 @@ option(BUILD_GUI "Build the GTK UI" ON) option(BUILD_CLI "Build the CLI" ON) set(CMAKE_C_STANDARD 11) -set(CMAKE_C_FLAGS "-Wall -Wextra -O2 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong -Wundef -Wmissing-format-attribute") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") +set(COMMON_C_FLAGS + "-Wall -Wextra -O3 -Wformat=2 -Wmissing-format-attribute -fstack-protector-strong" + "-Wundef -Wmissing-format-attribute -fdiagnostics-color=always" + "-Wstrict-prototypes -Wunreachable-code -Wchar-subscripts" + "-Wwrite-strings -Wpointer-arith -Wbad-function-cast -Wcast-align" + "-Werror=format-security -Werror=implicit-function-declaration -Wno-sign-compare" + "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3" +) + if(CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pie -fPIE") + list(APPEND COMMON_C_FLAGS "-pie -fPIE") endif() + if(IS_FLATPAK) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIS_FLATPAK") + list(APPEND COMMON_C_FLAGS "-DIS_FLATPAK") +endif() + +string(REPLACE ";" " " COMMON_C_FLAGS "${COMMON_C_FLAGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_C_FLAGS}") + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(COMMON_LINKER_FLAGS + "-Wl,--no-add-needed -Wl,--as-needed -Wl,--no-undefined" + "-Wl,-z,relro,-z,now" + ) + + string(REPLACE ";" " " COMMON_LINKER_FLAGS "${COMMON_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${COMMON_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${COMMON_LINKER_FLAGS}") endif() add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") @@ -83,22 +102,22 @@ if(BUILD_GUI) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "otpclient") install(TARGETS ${PROJECT_NAME} DESTINATION bin) - install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/applications) + install(FILES man/otpclient.1.gz DESTINATION share/man/man1) - install(FILES + set(GUI_UI_FILES src/gui/ui/otpclient.ui src/gui/ui/add_popover.ui src/gui/ui/settings_popover.ui src/gui/ui/shortcuts.ui - DESTINATION share/otpclient) - - install(FILES man/otpclient.1.gz DESTINATION share/man/man1) + ) + install(FILES ${GUI_UI_FILES} DESTINATION share/otpclient) - install(FILES + set(GUI_ICON_FILES data/icons/com.github.paolostivanin.OTPClient.svg data/icons/com.github.paolostivanin.OTPClient-symbolic.svg - DESTINATION share/icons/hicolor/scalable/apps) + ) + install(FILES ${GUI_ICON_FILES} DESTINATION share/icons/hicolor/scalable/apps) endif () if(BUILD_CLI) @@ -109,7 +128,6 @@ if(BUILD_CLI) set_target_properties(${PROJECT_NAME}-cli PROPERTIES OUTPUT_NAME "otpclient-cli") install(TARGETS ${PROJECT_NAME}-cli DESTINATION bin) - install(FILES man/otpclient-cli.1.gz DESTINATION share/man/man1) endif() diff --git a/src/gui/gui-misc.c b/src/gui/gui-misc.c index 0bacbbc..1e1499d 100644 --- a/src/gui/gui-misc.c +++ b/src/gui/gui-misc.c @@ -193,7 +193,7 @@ decode_migration_data (const gchar *encoded_uri) return NULL; } encoded_uri_copy += 33; - gsize out_len; + gsize out_len = 0; gchar *unesc_str = g_uri_unescape_string_secure (encoded_uri_copy, NULL); guchar *data = g_base64_decode_secure (unesc_str, &out_len); gcry_free (unesc_str); diff --git a/src/gui/ui/otpclient.ui b/src/gui/ui/otpclient.ui index e645875..8b78b37 100644 --- a/src/gui/ui/otpclient.ui +++ b/src/gui/ui/otpclient.ui @@ -265,6 +265,8 @@ center dialog center + 400 + 200 False