From 3a7897dea4c5d854732ddef5f4f3e80c3dbb0ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renato=20Foot=20Guimar=C3=A3es=20Costallat?= Date: Mon, 12 Aug 2024 18:07:08 -0300 Subject: [PATCH] fix: segfault on unit test (#2808) Fix segfault running unit test when building with linux-debug preset. --------- Co-authored-by: GitHub Actions --- .github/workflows/build-ubuntu.yml | 8 ++++---- src/security/argon.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 5109e613d99..2b369e34875 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -95,10 +95,10 @@ jobs: path: | ${{ github.workspace }}/build/${{ matrix.buildtype }}/bin/ -# - name: Run Unit Tests -# run: | -# cd ${{ github.workspace }}/build/${{ matrix.buildtype }}/tests/unit -# ctest --verbose + - name: Run Unit Tests + run: | + cd ${{ github.workspace }}/build/${{ matrix.buildtype }}/tests/unit + ctest --verbose # - name: Run Integration Tests # run: | diff --git a/src/security/argon.cpp b/src/security/argon.cpp index 02079e70ca0..fe11ab0724a 100644 --- a/src/security/argon.cpp +++ b/src/security/argon.cpp @@ -15,9 +15,6 @@ #include -const std::regex Argon2::re("\\$([A-Za-z0-9+/]+)\\$([A-Za-z0-9+/]+)"); -const std::string Argon2::base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - Argon2::Argon2() { updateConstants(); } @@ -44,6 +41,8 @@ uint32_t Argon2::parseBitShift(const std::string &bitShiftStr) const { } bool Argon2::verifyPassword(const std::string &password, const std::string &phash) const { + + const std::regex re("\\$([A-Za-z0-9+/]+)\\$([A-Za-z0-9+/]+)"); std::smatch match; if (!std::regex_search(phash, match, re)) { g_logger().debug("No argon2 hash found in string"); @@ -65,6 +64,7 @@ bool Argon2::verifyPassword(const std::string &password, const std::string &phas } std::vector Argon2::base64_decode(const std::string &input) const { + const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; std::vector ret; int i = 0; uint32_t val = 0;