From 5d82a637f8fc4f14c672b297de876276cabcc627 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 6 Jul 2015 20:48:43 +0200 Subject: Fix to_string for BER_Object when debug STL is used --- src/lib/asn1/asn1_obj.cpp | 4 ++-- src/lib/utils/stl_util.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/asn1/asn1_obj.cpp b/src/lib/asn1/asn1_obj.cpp index 265668d83..20555e3dd 100644 --- a/src/lib/asn1/asn1_obj.cpp +++ b/src/lib/asn1/asn1_obj.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace Botan { @@ -45,8 +46,7 @@ std::vector put_in_sequence(const std::vector& contents) */ std::string to_string(const BER_Object& obj) { - return std::string(reinterpret_cast(&obj.value[0]), - obj.value.size()); + return to_string(obj.value); } /* diff --git a/src/lib/utils/stl_util.h b/src/lib/utils/stl_util.h index 76cf77ef8..d74cbe713 100644 --- a/src/lib/utils/stl_util.h +++ b/src/lib/utils/stl_util.h @@ -1,6 +1,7 @@ /* * STL Utility Functions * (C) 1999-2007 Jack Lloyd +* (C) 2015 Simon Warta (Kullo GmbH) * * Botan is released under the Simplified BSD License (see license.txt) */ @@ -11,6 +12,7 @@ #include #include #include +#include namespace Botan { @@ -19,6 +21,11 @@ inline std::vector to_byte_vector(const std::string& s) return std::vector(s.cbegin(), s.cend()); } +inline std::string to_string(const secure_vector &bytes) + { + return std::string(bytes.cbegin(), bytes.cend()); + } + /* * Searching through a std::map * @param mapping the map to search -- cgit v1.2.3