From 1c0b697a59472445e7b8847e566974b503ce012d Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 4 Aug 2019 04:36:59 +0700 Subject: CLOUD: Fix OneDriveTokenRefresher If user doesn't have a "saves" folder, listing it as a first step of syncing save files would result in 404 from OneDrive. OneDriveTokenRefresher handles token-related errors (401), so when it meets 404, it calls its finishError method. But because there was some strange behaviour from OneDrive with sending invalid JSON, this method tries fixing JSON and parsing it again. If it is valid, it calls non-error method again, and in result we get stack overflow. In order to fix that, I've added a non-JSON prefix "", so finishError won't be able to parse JSON and thus won't call finishJson again. Saves syncing callback does check string contents apart from trying to parse JSON, so it still works and correctly handles the situation when "saves" directory is missing. But, if needed, code can be updated to search for the prefix I've added and remove it before parsing original JSON. --- backends/cloud/onedrive/onedrivetokenrefresher.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/cloud/onedrive/onedrivetokenrefresher.cpp b/backends/cloud/onedrive/onedrivetokenrefresher.cpp index 1654869e07..10992c5927 100644 --- a/backends/cloud/onedrive/onedrivetokenrefresher.cpp +++ b/backends/cloud/onedrive/onedrivetokenrefresher.cpp @@ -98,7 +98,8 @@ void OneDriveTokenRefresher::finishJson(Common::JSONValue *json) { irrecoverable = false; if (irrecoverable) { - finishError(Networking::ErrorResponse(this, false, true, json->stringify(true), httpResponseCode)); + Common::String errorContents = " " + json->stringify(true); + finishError(Networking::ErrorResponse(this, false, true, errorContents, httpResponseCode)); delete json; return; } -- cgit v1.2.3