From ca4f70db221d4e3968e4f695fd5c9ee79da8e6f0 Mon Sep 17 00:00:00 2001 From: Celerizer Date: Tue, 24 Apr 2018 21:31:07 -0500 Subject: [PATCH 1/4] [Cheevos] Store only login token, not password --- cheevos/cheevos.c | 103 +++++++++++++++++++++++++++++++++++----------- configuration.c | 2 + configuration.h | 1 + 3 files changed, 81 insertions(+), 25 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 35d4857b55..046bf53620 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -107,6 +107,8 @@ #define CHEEVOS_JSON_KEY_LEADERBOARDS 0xf1247d2dU #define CHEEVOS_JSON_KEY_MEM 0x0b8807e4U #define CHEEVOS_JSON_KEY_FORMAT 0xb341208eU +#define CHEEVOS_JSON_KEY_SUCCESS 0x110461deU +#define CHEEVOS_JSON_KEY_ERROR 0x0d2011cfU typedef struct { @@ -3587,29 +3589,46 @@ found: { char urle_user[64]; - char urle_pwd[64]; + char urle_login[64]; const char *username = coro ? coro->settings->arrays.cheevos_username : NULL; - const char *password = coro ? coro->settings->arrays.cheevos_password : NULL; + const char *login; + bool via_token; - if (!username || !*username || !password || !*password) + if (coro) + { + if (string_is_empty(coro->settings->arrays.cheevos_password)) + { + via_token = true; + login = coro->settings->arrays.cheevos_token; + } + else + { + via_token = false; + login = coro->settings->arrays.cheevos_password; + } + } + else + login = NULL; + + if (string_is_empty(username) || string_is_empty(login)) { runloop_msg_queue_push( - "Missing Retro Achievements account information.", + "Missing RetroAchievements account information.", 0, 5 * 60, false); runloop_msg_queue_push( "Please fill in your account information in Settings.", 0, 5 * 60, false); - RARCH_ERR("[CHEEVOS]: username and/or password not informed.\n"); + RARCH_ERR("[CHEEVOS]: login info not informed.\n"); CORO_STOP(); } cheevos_url_encode(username, urle_user, sizeof(urle_user)); - cheevos_url_encode(password, urle_pwd, sizeof(urle_pwd)); + cheevos_url_encode(login, urle_login, sizeof(urle_login)); snprintf( coro->url, sizeof(coro->url), - "http://retroachievements.org/dorequest.php?r=login&u=%s&p=%s", - urle_user, urle_pwd + "http://retroachievements.org/dorequest.php?r=login&u=%s&%c=%s", + urle_user, via_token ? 't' : 'p', urle_login ); coro->url[sizeof(coro->url) - 1] = 0; @@ -3624,32 +3643,66 @@ found: if (coro->json) { - int res = cheevos_get_value( + char error_response[64]; + cheevos_get_value( + coro->json, + CHEEVOS_JSON_KEY_ERROR, + error_response, + sizeof(error_response) + ); + + /* No error, continue with login */ + if (string_is_empty(error_response)) + { + int res = cheevos_get_value( coro->json, CHEEVOS_JSON_KEY_TOKEN, cheevos_locals.token, sizeof(cheevos_locals.token)); + if ((void*)coro->json) + free((void*)coro->json); + + if (!res) + { + if (coro->settings->bools.cheevos_verbose_enable) + { + char msg[256]; + snprintf(msg, sizeof(msg), + "RetroAchievements: Logged in as \"%s\".", + coro->settings->arrays.cheevos_username); + msg[sizeof(msg) - 1] = 0; + runloop_msg_queue_push(msg, 0, 3 * 60, false); + } + + /* Save token to config and clear pass on success */ + *coro->settings->arrays.cheevos_password = '\0'; + strncpy( + coro->settings->arrays.cheevos_token, + cheevos_locals.token, sizeof(cheevos_locals.token) + ); + CORO_RET(); + } + } + if ((void*)coro->json) free((void*)coro->json); - - if (!res) - { - if (coro->settings->bools.cheevos_verbose_enable) - { - char msg[256]; - snprintf(msg, sizeof(msg), - "RetroAchievements: logged in as \"%s\".", - coro->settings->arrays.cheevos_username); - msg[sizeof(msg) - 1] = 0; - runloop_msg_queue_push(msg, 0, 3 * 60, false); - } - CORO_RET(); - } + + /* Site returned error, display it */ + char error_message[256]; + snprintf(error_message, sizeof(error_message), + "RetroAchievements: %s", + error_response); + error_message[sizeof(error_message) - 1] = 0; + runloop_msg_queue_push(error_message, 0, 5 * 60, false); + *coro->settings->arrays.cheevos_token = '\0'; + + CORO_STOP(); } - - runloop_msg_queue_push("Retro Achievements login error.", 0, 5 * 60, false); + + runloop_msg_queue_push("RetroAchievements: Error contacting server.", 0, 5 * 60, false); RARCH_ERR("[CHEEVOS]: error getting user token.\n"); + CORO_STOP(); /************************************************************************** diff --git a/configuration.c b/configuration.c index 7fac707d6c..5a8a78b8aa 100644 --- a/configuration.c +++ b/configuration.c @@ -1033,6 +1033,7 @@ static struct config_array_setting *populate_settings_array(settings_t *settings #ifdef HAVE_CHEEVOS SETTING_ARRAY("cheevos_username", settings->arrays.cheevos_username, false, NULL, true); SETTING_ARRAY("cheevos_password", settings->arrays.cheevos_password, false, NULL, true); + SETTING_ARRAY("cheevos_token", settings->arrays.cheevos_token, false, NULL, true); #endif SETTING_ARRAY("video_context_driver", settings->arrays.video_context_driver, false, NULL, true); SETTING_ARRAY("audio_driver", settings->arrays.audio_driver, false, NULL, true); @@ -1724,6 +1725,7 @@ static void config_set_defaults(void) #ifdef HAVE_CHEEVOS *settings->arrays.cheevos_username = '\0'; *settings->arrays.cheevos_password = '\0'; + *settings->arrays.cheevos_token = '\0'; #endif input_config_reset(); diff --git a/configuration.h b/configuration.h index 3f5fca1ded..89a53b6b42 100644 --- a/configuration.h +++ b/configuration.h @@ -411,6 +411,7 @@ typedef struct settings char menu_driver[32]; char cheevos_username[32]; char cheevos_password[32]; + char cheevos_token[32]; char video_context_driver[32]; char audio_driver[32]; char audio_resampler[32]; From 634416290035bc64dfb9041ea118bda994efaa47 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 25 Apr 2018 10:13:57 +0200 Subject: [PATCH 2/4] Update CHANGES.md --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 45f39f49df..7e1d62cc86 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ - COMMON: Fix invalid long command line options causing infinite loop on Windows - COMMON: Add OSD statistics for video/audio/core. - COMMON: Added runahead system; allows you to drive down latency even further. +- COMMON: Fix buggy behavior that could happen with ZIP file reading on some platforms as a result of not initializing struct. - CHEEVOS: Support Atari 2600, Virtual Boy, and Arcade (only Neo Geo, CPS-1, CPS-2 and CPS-3 and only with fbalpha core). - CHEEVOS: Add option to automatically take a screenshot when an achievement is triggered. - CHEEVOS: Fixed incompatibilities with Neo Geo Pocket achievement sets. @@ -57,7 +58,7 @@ that support it (so far this includes - D3D8/D3D9, OpenGL, Vulkan) - WINDOWS/MSVC 2003/2005/2010/2013/2015/2017: Add Cheevos support. - VITA: Bugfix for 'PS Vita takes many time to start to accept input' issue. - X11: Allow compositor disabling on X11 fullscreen through _NET_WM_BYPASS_COMPOSITOR -- X11: Prioritize _NET_WM_STATE_FULLSCREEN in true fullscreen mode +- X11: Prioritize _NET_WM_STATE_FULLSCREEN_ in true fullscreen mode - WIIU: Fix OOB read/write in keyboard driver. # 1.7.1 From 7902a606698e61cb2e56909c45845d90dc224f5e Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 25 Apr 2018 10:15:40 +0200 Subject: [PATCH 3/4] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 7e1d62cc86..6a84b56d14 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ - CHEEVOS: Support Atari 2600, Virtual Boy, and Arcade (only Neo Geo, CPS-1, CPS-2 and CPS-3 and only with fbalpha core). - CHEEVOS: Add option to automatically take a screenshot when an achievement is triggered. - CHEEVOS: Fixed incompatibilities with Neo Geo Pocket achievement sets. +- CHEEVOS: Store only login token, not password. - D3D10: Added D3D10 driver to release build. Has working shaders (Slang), overlay, and menu display driver support. Should be on par capabilities wise with D3D11 driver except for there being no hardware rendering right now. - D3D11: Experimental hardware renderer. Allows for libretro cores to use D3D11 for hardware rendering. First core to use this is PPSSPP. From fee49f0e7e2bb7a4172dd2b445d3a85b78ee0620 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 25 Apr 2018 10:21:26 +0200 Subject: [PATCH 4/4] Update libretro-common --- libretro-common/audio/audio_mixer.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libretro-common/audio/audio_mixer.c b/libretro-common/audio/audio_mixer.c index 4dffa95c84..7988ff6517 100644 --- a/libretro-common/audio/audio_mixer.c +++ b/libretro-common/audio/audio_mixer.c @@ -44,7 +44,7 @@ #define STB_VORBIS_NO_STDIO #define STB_VORBIS_NO_CRT -#include +#include #endif #ifdef HAVE_IBXM @@ -412,7 +412,7 @@ static bool audio_mixer_play_ogg( { stb_vorbis_info info; int res = 0; - float ratio = 0.0f; + float ratio = 1.0f; unsigned samples = 0; void *ogg_buffer = NULL; void *resampler_data = NULL; @@ -665,8 +665,8 @@ static void audio_mixer_mix_ogg(float* buffer, size_t num_frames, float volume) { int i; - struct resampler_data info; - float temp_buffer[AUDIO_MIXER_TEMP_OGG_BUFFER]; + struct resampler_data info = { 0 }; + float temp_buffer[AUDIO_MIXER_TEMP_OGG_BUFFER] = { 0 }; unsigned buf_free = (unsigned)(num_frames * 2); unsigned temp_samples = 0; float* pcm = NULL; @@ -704,7 +704,10 @@ again: info.output_frames = 0; info.ratio = voice->types.ogg.ratio; - voice->types.ogg.resampler->process(voice->types.ogg.resampler_data, &info); + if (voice->types.ogg.resampler) + voice->types.ogg.resampler->process(voice->types.ogg.resampler_data, &info); + else + memcpy(voice->types.ogg.buffer, temp_buffer, temp_samples * sizeof(float)); voice->types.ogg.position = 0; voice->types.ogg.samples = voice->types.ogg.buf_samples; }