From 392ebaab91c4fc1e55545da47400dcfb3f43491a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 12 May 2019 11:05:37 +0100 Subject: [PATCH] Added secure clear to strings. --- include/etl/basic_string.h | 7 ++++++- include/etl/version.h | 4 ++-- support/Release notes.txt | 5 +++++ test/test_string_char.cpp | 10 +++++----- test/test_string_u16.cpp | 10 +++++----- test/test_string_u32.cpp | 10 +++++----- test/test_string_wchar_t.cpp | 10 +++++----- 7 files changed, 33 insertions(+), 23 deletions(-) diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index cda271f1..e3effdf0 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -2076,9 +2076,14 @@ namespace etl } } - // Disable copy construction. + //************************************************************************* + /// Disable copy construction. + //************************************************************************* ibasic_string(const ibasic_string&); + //************************************************************************* + /// Pointer to the string's buffer. + //************************************************************************* T* p_buffer; //************************************************************************* diff --git a/include/etl/version.h b/include/etl/version.h index ab365918..da98a129 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,8 +38,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 14 -#define ETL_VERSION_MINOR 22 -#define ETL_VERSION_PATCH 1 +#define ETL_VERSION_MINOR 23 +#define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_CONCAT(ETL_CONCAT(ETL_VERSION_MAJOR, ETL_VERSION_MINOR), ETL_VERSION_PATCH)) diff --git a/support/Release notes.txt b/support/Release notes.txt index e4201fa2..42f12388 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +14.23.0 +Added an optional secure mode to strings so that unused space will be cleared to zero +and also cleared on destruction. + =============================================================================== 14.22.1 Modified memory functions so that they will not be optimised away. diff --git a/test/test_string_char.cpp b/test/test_string_char.cpp index 10c108ba..9d5644fc 100644 --- a/test/test_string_char.cpp +++ b/test/test_string_char.cpp @@ -3671,7 +3671,7 @@ namespace text.~Text(); // Check there no non-zero values in the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3686,7 +3686,7 @@ namespace text.assign(STR("ABC")); - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3702,7 +3702,7 @@ namespace text.erase(pb + 2, pb + 5); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3718,7 +3718,7 @@ namespace text.replace(pb + 1, pb + 4, STR("G")); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3734,7 +3734,7 @@ namespace text.clear(); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } }; } diff --git a/test/test_string_u16.cpp b/test/test_string_u16.cpp index c2b6067c..08382b8c 100644 --- a/test/test_string_u16.cpp +++ b/test/test_string_u16.cpp @@ -3670,7 +3670,7 @@ namespace text.~Text(); // Check there no non-zero values in the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3685,7 +3685,7 @@ namespace text.assign(STR("ABC")); - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3701,7 +3701,7 @@ namespace text.erase(pb + 2, pb + 5); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3717,7 +3717,7 @@ namespace text.replace(pb + 1, pb + 4, STR("G")); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3733,7 +3733,7 @@ namespace text.clear(); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } }; } diff --git a/test/test_string_u32.cpp b/test/test_string_u32.cpp index cbdd7f45..55e9400a 100644 --- a/test/test_string_u32.cpp +++ b/test/test_string_u32.cpp @@ -3670,7 +3670,7 @@ namespace text.~Text(); // Check there no non-zero values in the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3685,7 +3685,7 @@ namespace text.assign(STR("ABC")); - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3701,7 +3701,7 @@ namespace text.erase(pb + 2, pb + 5); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3717,7 +3717,7 @@ namespace text.replace(pb + 1, pb + 4, STR("G")); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3733,7 +3733,7 @@ namespace text.clear(); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } }; } diff --git a/test/test_string_wchar_t.cpp b/test/test_string_wchar_t.cpp index 463b029f..a00d8e02 100644 --- a/test/test_string_wchar_t.cpp +++ b/test/test_string_wchar_t.cpp @@ -3670,7 +3670,7 @@ namespace text.~Text(); // Check there no non-zero values in the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3685,7 +3685,7 @@ namespace text.assign(STR("ABC")); - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3701,7 +3701,7 @@ namespace text.erase(pb + 2, pb + 5); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3717,7 +3717,7 @@ namespace text.replace(pb + 1, pb + 4, STR("G")); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(text.end(), pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(text.end(), pe, [](Text::value_type x) { return x != 0; }) == pe); } //************************************************************************* @@ -3733,7 +3733,7 @@ namespace text.clear(); // Check there no non-zero values in the remainder of the string. - CHECK(std::find_if(pb, pe, [](auto x) { return x != 0; }) == pe); + CHECK(std::find_if(pb, pe, [](Text::value_type x) { return x != 0; }) == pe); } }; }