From 9b670e5b33dfdbd501d618cd7e7498148ffbd559 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Mon, 25 Mar 2019 17:50:39 -0700 Subject: [PATCH] Fix oauth nonces containing nulls. (#1084) --- Release/src/utilities/asyncrt_utils.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Release/src/utilities/asyncrt_utils.cpp b/Release/src/utilities/asyncrt_utils.cpp index 7867e6ec55..4a692e5fad 100644 --- a/Release/src/utilities/asyncrt_utils.cpp +++ b/Release/src/utilities/asyncrt_utils.cpp @@ -1393,15 +1393,16 @@ utility::seconds __cdecl timespan::xml_duration_to_seconds(const utility::string return utility::seconds(numSecs); } -static const utility::char_t c_allowed_chars[] = - _XPLATSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); +static const char c_allowed_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; +static const int chars_count = static_cast(sizeof(c_allowed_chars) - 1); utility::string_t nonce_generator::generate() { - std::uniform_int_distribution<> distr(0, static_cast(sizeof(c_allowed_chars) / sizeof(utility::char_t)) - 1); + std::uniform_int_distribution<> distr(0, chars_count - 1); utility::string_t result; result.reserve(length()); - std::generate_n(std::back_inserter(result), length(), [&]() { return c_allowed_chars[distr(m_random)]; }); + std::generate_n(std::back_inserter(result), length(), + [&] { return static_cast(c_allowed_chars[distr(m_random)]); }); return result; }