From fdd4c5e5770c2765afd7734550dc80e31a480045 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 21 Dec 2017 14:51:29 +0000 Subject: [PATCH] move memwipe to epee to avoid common<->crypto circular dependencies --- {src/common => contrib/epee/include}/memwipe.h | 0 contrib/epee/src/CMakeLists.txt | 6 +++++- {src/common => contrib/epee/src}/memwipe.c | 0 src/common/CMakeLists.txt | 6 ------ src/common/password.cpp | 2 +- src/crypto/chacha.h | 2 +- src/crypto/crypto.h | 2 +- src/wallet/wallet2.cpp | 2 +- tests/unit_tests/memwipe.cpp | 2 +- 9 files changed, 10 insertions(+), 12 deletions(-) rename {src/common => contrib/epee/include}/memwipe.h (100%) rename {src/common => contrib/epee/src}/memwipe.c (100%) diff --git a/src/common/memwipe.h b/contrib/epee/include/memwipe.h similarity index 100% rename from src/common/memwipe.h rename to contrib/epee/include/memwipe.h diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index ee118724d..9d104ceeb 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -26,12 +26,16 @@ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -add_library(epee STATIC hex.cpp http_auth.cpp mlog.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp +add_library(epee STATIC hex.cpp http_auth.cpp mlog.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp) if (USE_READLINE AND GNU_READLINE_FOUND) add_library(epee_readline STATIC readline_buffer.cpp) endif() +if(HAVE_C11) +SET_PROPERTY(SOURCE memwipe.c PROPERTY COMPILE_FLAGS -std=c11) +endif() + # Build and install libepee if we're building for GUI if (BUILD_GUI_DEPS) if(IOS) diff --git a/src/common/memwipe.c b/contrib/epee/src/memwipe.c similarity index 100% rename from src/common/memwipe.c rename to contrib/epee/src/memwipe.c diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 7ad08ea83..50887e35c 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -35,7 +35,6 @@ set(common_sources download.cpp util.cpp i18n.cpp - memwipe.c password.cpp perf_timer.cpp threadpool.cpp @@ -64,7 +63,6 @@ set(common_private_headers util.h varint.h i18n.h - memwipe.h password.h perf_timer.h stack_trace.h @@ -92,9 +90,5 @@ target_link_libraries(common ${OPENSSL_LIBRARIES} ${EXTRA_LIBRARIES}) -if(HAVE_C11) -SET_PROPERTY(SOURCE memwipe.c PROPERTY COMPILE_FLAGS -std=c11) -endif() - #monero_install_headers(common # ${common_headers}) diff --git a/src/common/password.cpp b/src/common/password.cpp index dc0856160..011123300 100644 --- a/src/common/password.cpp +++ b/src/common/password.cpp @@ -46,7 +46,7 @@ #include "readline_buffer.h" #endif -#include "common/memwipe.h" +#include "memwipe.h" namespace { diff --git a/src/crypto/chacha.h b/src/crypto/chacha.h index a9665030d..c11e4aa2f 100644 --- a/src/crypto/chacha.h +++ b/src/crypto/chacha.h @@ -39,7 +39,7 @@ #if defined(__cplusplus) #include -#include "common/memwipe.h" +#include "memwipe.h" #include "hash.h" namespace crypto { diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index 0ce5e6d7a..a929302c1 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -41,7 +41,7 @@ #include "common/pod-class.h" #include "common/util.h" -#include "common/memwipe.h" +#include "memwipe.h" #include "generic-ops.h" #include "hex.h" #include "span.h" diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index c4f8f3457..724d19efd 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -62,7 +62,7 @@ using namespace epee; #include "rapidjson/writer.h" #include "rapidjson/stringbuffer.h" #include "common/json_util.h" -#include "common/memwipe.h" +#include "memwipe.h" #include "common/base58.h" #include "ringct/rctSigs.h" diff --git a/tests/unit_tests/memwipe.cpp b/tests/unit_tests/memwipe.cpp index 2d8980ef7..59f50cef8 100644 --- a/tests/unit_tests/memwipe.cpp +++ b/tests/unit_tests/memwipe.cpp @@ -30,7 +30,7 @@ #include #include "misc_log_ex.h" -#include "common/memwipe.h" +#include "memwipe.h" // Probably won't catch the optimized out case, but at least we test // it works in the normal case