From b4ace6ec6f86079b3bd297f95dfe133240b53e15 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Mon, 17 Sep 2018 17:16:01 +0200 Subject: Address a bunch of review comments --- src/core/telemetry_session.cpp | 11 ++++++----- src/core/telemetry_session.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 09c85297a..c02188adc 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -28,11 +28,12 @@ static u64 GenerateTelemetryId() { mbedtls_entropy_context entropy; mbedtls_entropy_init(&entropy); mbedtls_ctr_drbg_context ctr_drbg; - const char* personalization = "yuzu Telemetry ID"; + std::string personalization = "yuzu Telemetry ID"; mbedtls_ctr_drbg_init(&ctr_drbg); - mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, - (const unsigned char*)personalization, strlen(personalization)); + ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, + reinterpret_cast(personalization.c_str()), + personalization.size()) == 0) ASSERT(mbedtls_ctr_drbg_random(&ctr_drbg, reinterpret_cast(&telemetry_id), sizeof(u64)) == 0); @@ -88,7 +89,7 @@ u64 RegenerateTelemetryId() { return new_telemetry_id; } -bool VerifyLogin(std::string username, std::string token) { +bool VerifyLogin(const std::string& username, const std::string& token) { #ifdef ENABLE_WEB_SERVICE return WebService::VerifyLogin(Settings::values.web_api_url, username, token); #else @@ -120,7 +121,7 @@ TelemetrySession::TelemetrySession() { u64 program_id{}; const Loader::ResultStatus res{System::GetInstance().GetAppLoader().ReadProgramId(program_id)}; if (res == Loader::ResultStatus::Success) { - std::string formatted_program_id{fmt::format("{:016X}", program_id)}; + const std::string formatted_program_id{fmt::format("{:016X}", program_id)}; AddField(Telemetry::FieldType::Session, "ProgramId", formatted_program_id); std::string name; diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index e6976ad45..cec271df0 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h @@ -56,6 +56,6 @@ u64 RegenerateTelemetryId(); * @param func A function that gets exectued when the verification is finished * @returns Future with bool indicating whether the verification succeeded */ -bool VerifyLogin(std::string username, std::string token); +bool VerifyLogin(const std::string& username, const std::string& token); } // namespace Core -- cgit v1.2.3