Play your Steam library's Windows games on a jailbroken PS5.
C++
Let one odd license stop blocking every install
Leonardo Lobato40c4ff9f993f
diff --git a/src/steam/backend/cm_client.cpp b/src/steam/backend/cm_client.cppindex c81a228..90adc90 100644--- a/src/steam/backend/cm_client.cpp+++ b/src/steam/backend/cm_client.cpp@@ -947,10 +947,11 @@ AcquisitionResult CmClient::FetchAcquisitionDates(const StoredSession& stored,for (const auto& package : part.packages) {if (!wanted.count(package.package_id)) continue;PackageContents contents;+ // One odd license must not block every install (issue #1): skip it, its apps stay unowned.if (package.missing_token ||!ParsePackageBuffer(package.buffer.data(), package.buffer.size(), package.package_id,&contents))- return finish(CmError::kProtocol);+ continue;auto& apps = package_apps[package.package_id];apps.insert(apps.end(), contents.app_ids.begin(), contents.app_ids.end());result.owned_apps.insert(contents.app_ids.begin(), contents.app_ids.end());@@ -958,8 +959,10 @@ AcquisitionResult CmClient::FetchAcquisitionDates(const StoredSession& stored,received.insert(package.package_id);}}- if (received != wanted) return finish(CmError::kProtocol);+ result.skipped_packages += static_cast<std::uint32_t>(wanted.size() - received.size());}+ // Nothing usable at all is a reply this client does not understand, not a few odd licenses.+ if (!packages.empty() && result.skipped_packages == packages.size()) return finish(CmError::kProtocol);const auto now = hooks_.unix_now? hooks_.unix_now()diff --git a/src/steam/backend/cm_client.h b/src/steam/backend/cm_client.hindex 4bcb592..10b8cf1 100644--- a/src/steam/backend/cm_client.h+++ b/src/steam/backend/cm_client.h@@ -52,6 +52,8 @@ struct AcquisitionResult {// Apps and depots granted by those licenses' packages, for depot selection.std::set<std::uint32_t> owned_apps;std::set<std::uint32_t> owned_depots;+ // Licensed packages Steam left out, sent without a token, or sent unreadable; their apps are not owned here.+ std::uint32_t skipped_packages = 0;bool ok() const { return error == CmError::kNone; }};diff --git a/src/steam/backend/steam_install_runner.cpp b/src/steam/backend/steam_install_runner.cppindex 7b183b9..49895a0 100644--- a/src/steam/backend/steam_install_runner.cpp+++ b/src/steam/backend/steam_install_runner.cpp@@ -110,6 +110,8 @@ InstallRunner::Result SteamInstallRunner::Install(const StoredSession& session,result.failure = "Could not read this account's licenses. Resume to try again.";return result;}+ if (entitlements.skipped_packages)+ log("entitlements", "partial", ("skipped_packages=" + std::to_string(entitlements.skipped_packages)).c_str());std::set<std::uint32_t> owned_apps = entitlements.owned_apps;owned_apps.insert(id);if (!SelectDepots(*app, owned_apps, entitlements.owned_depots, &target.depots, &reason)) {diff --git a/tests/cm_client_test.cpp b/tests/cm_client_test.cppindex 385f847..082d442 100644--- a/tests/cm_client_test.cpp+++ b/tests/cm_client_test.cpp@@ -214,14 +214,39 @@ void FailedLicenseListIsRejected() {assert(client.FetchAcquisitionDates(Session(), cancel).error == CmError::kRejected);}-void IncompletePicsIsAProtocolError() {- auto script = HappyScript();- // Only the first part, already marked final by a server-side job eresult-less frame.- auto part = Fixture("pics_response_part2.pb"); // package 200 only, not pending- script->on_pics = {ServerFrame(cm::kEMsgClientPICSProductInfoResponse, part, std::nullopt, 1)};- auto client = MakeClient(script);+// One odd license must not block every install (issue #1): a package Steam leaves out or sends without its token is+// skipped, and only its apps stay unowned.+void PackagesSteamCannotDescribeAreSkipped() {std::atomic<bool> cancel{false};- assert(client.FetchAcquisitionDates(Session(), cancel).error == CmError::kProtocol);+ // Package 100 is left out; the reply holds package 200 only, not pending.+ auto left_out = HappyScript();+ left_out->on_pics = {ServerFrame(cm::kEMsgClientPICSProductInfoResponse, Fixture("pics_response_part2.pb"), std::nullopt, 1)};+ auto client = MakeClient(left_out);+ const auto partial = client.FetchAcquisitionDates(Session(), cancel);+ assert(partial.ok() && partial.skipped_packages == 1);+ assert(partial.owned_apps == (std::set<std::uint32_t>{20, 30}));+ assert(partial.acquired_at.size() == 2 && partial.acquired_at.at(20) == 1500000000u);++ // Package 100 comes back marked as missing its token, with no buffer.+ auto tokenless = HappyScript();+ auto body = Fixture("pics_response_part2.pb");+ proto::Writer entry;+ entry.AddVarint(1, 100);+ entry.AddVarint(3, 1);+ proto::Writer missing;+ missing.AddMessage(3, entry);+ body.insert(body.end(), missing.bytes().begin(), missing.bytes().end());+ tokenless->on_pics = {ServerFrame(cm::kEMsgClientPICSProductInfoResponse, body, std::nullopt, 1)};+ auto other = MakeClient(tokenless);+ const auto skipped = other.FetchAcquisitionDates(Session(), cancel);+ assert(skipped.ok() && skipped.skipped_packages == 1 && skipped.owned_apps == (std::set<std::uint32_t>{20, 30}));++ // A reply with none of the packages is still a protocol error.+ auto empty = HappyScript();+ empty->on_pics = {ServerFrame(cm::kEMsgClientPICSProductInfoResponse, {}, std::nullopt, 1)};+ auto third = MakeClient(empty);+ const auto none = third.FetchAcquisitionDates(Session(), cancel);+ assert(none.error == CmError::kProtocol && none.owned_apps.empty());}void JobErrorResultFailsTheBatch() {@@ -588,7 +613,7 @@ int main(int argc, char** argv) {ResetCmBackoff();FailedLicenseListIsRejected();ResetCmBackoff();- IncompletePicsIsAProtocolError();+ PackagesSteamCannotDescribeAreSkipped();ResetCmBackoff();JobErrorResultFailsTheBatch();ResetCmBackoff();