This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/main by this push:
     new 50ee1d2  DISPATCH-2328: detect _FORTIFY_SOURCE in c_unittests and bail 
out (#1514)
50ee1d2 is described below

commit 50ee1d2e6a0ec9497b56024da41717e8423f11ad
Author: Jiri DanÄ›k <[email protected]>
AuthorDate: Thu Feb 10 23:03:37 2022 +0100

    DISPATCH-2328: detect _FORTIFY_SOURCE in c_unittests and bail out (#1514)
---
 tests/c_unittests/CMakeLists.txt       | 2 +-
 tests/c_unittests/c_unittests_main.cpp | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tests/c_unittests/CMakeLists.txt b/tests/c_unittests/CMakeLists.txt
index 5a9a9e5..7742acb 100644
--- a/tests/c_unittests/CMakeLists.txt
+++ b/tests/c_unittests/CMakeLists.txt
@@ -20,7 +20,7 @@
 # -fno-inline: just to be extra sure, no particular reason so far
 # -fno-builtin: GCC would optimize e.g. abs() and we would not be able to stub
 # -fno-stack-protector: 
https://stackoverflow.com/questions/12201625/disable-using-sprintf-chk
-# -D_FORTIFY_SOURCE=0: for Ubuntu with -O1+, 
https://stackoverflow.com/questions/34907503/gcc-fread-chk-warn-warning
+# -U_FORTIFY_SOURCE: for Ubuntu with -O1+, 
https://stackoverflow.com/questions/34907503/gcc-fread-chk-warn-warning
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD_FLAGS} -fno-inline 
-fno-builtin -fno-stack-protector -U_FORTIFY_SOURCE")
 # DISPATCH-2196 Linking object files containing instances of the same C++ 
template fails on s390x with sanitizers enabled
 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x")
diff --git a/tests/c_unittests/c_unittests_main.cpp 
b/tests/c_unittests/c_unittests_main.cpp
index de06ee2..d93d9f8 100644
--- a/tests/c_unittests/c_unittests_main.cpp
+++ b/tests/c_unittests/c_unittests_main.cpp
@@ -28,24 +28,28 @@
 bool check_stubbing_works()
 {
 
+#if (defined(_FORTIFY_SOURCE))
+    return false; // special checked glibc functions were substituted
+#endif
 #if (defined(__s390__) || defined(__s390x__) || defined(__zarch__))
     return false; // cpp-stub does not support
 #endif
 
     {
         Stub stub;
-        stub.set(probe, +[](int)->int { return 42; });
+        stub.set(probe, +[](int) -> int { return 42; });
         if (probe(0) != 42) {
             return false;
         }
     }
     {
         Stub stub;
-        stub.set(abs, +[](int)->int{ return 24; });
+        stub.set(abs, +[](int) -> int { return 24; });
         if (probe(0) != 24) {
             return false;
         }
     }
+
     return true;
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to