Skip to content

Commit

Permalink
Fix oauth nonces containing nulls. (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal authored Mar 26, 2019
1 parent f10d9f8 commit 9b670e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Release/src/utilities/asyncrt_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(sizeof(c_allowed_chars) - 1);

utility::string_t nonce_generator::generate()
{
std::uniform_int_distribution<> distr(0, static_cast<int>(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<utility::char_t>(c_allowed_chars[distr(m_random)]); });
return result;
}

Expand Down

0 comments on commit 9b670e5

Please sign in to comment.