From 7e05e12b833e19333ffac02e4fec72250c8b17fa Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 12 May 2021 22:43:39 -0700 Subject: [PATCH] sf/tipc: treat min/max as true min/max, rather than numeric --- .../stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp | 5 ++++- .../stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp index 47b359866..827147576 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp @@ -54,7 +54,10 @@ namespace ams::sf::cmif { Result (*handler)(CmifOutHeader **out_header_ptr, ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data); constexpr inline bool Matches(u32 cmd_id, hos::Version hosver) const { - return this->cmd_id == cmd_id && this->hosver_low <= hosver && hosver <= this->hosver_high; + const bool min_valid = this->hosver_low == hos::Version_Min; + const bool max_valid = this->hosver_high == hos::Version_Max; + + return this->cmd_id == cmd_id && (min_valid || this->hosver_low <= hosver) && (max_valid || hosver <= this->hosver_high); } constexpr inline decltype(handler) GetHandler() const { diff --git a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp index 5c0ac16d9..f7ce54bf9 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/impl/tipc_autogen_interface_macros.hpp @@ -79,8 +79,9 @@ namespace ams::tipc::impl { #define AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \ if constexpr (constexpr u16 TipcCommandId = CMD_ID + 0x10; CommandId == TipcCommandId) { \ - constexpr bool AlwaysValid = VERSION_MIN == hos::Version_Min && VERSION_MAX == hos::Version_Max; \ - if (AlwaysValid || (VERSION_MIN <= fw_ver && fw_ver <= VERSION_MAX)) { \ + constexpr bool MinValid = VERSION_MIN == hos::Version_Min; \ + constexpr bool MaxValid = VERSION_MAX == hos::Version_Max; \ + if ((MinValid || VERSION_MIN <= fw_ver) && (MaxValid || fw_ver <= VERSION_MAX)) { \ return ::ams::tipc::impl::InvokeServiceCommandImpl(impl, message_buffer); \ } \ }