diff options
| -rw-r--r-- | src/core/hle/service/lm/lm.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/ns/pl_u.cpp | 9 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index 2a6d43d2a..7d7542fc2 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp | |||
| @@ -143,17 +143,19 @@ private: | |||
| 143 | rb.Push(RESULT_SUCCESS); | 143 | rb.Push(RESULT_SUCCESS); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | u32 ReadLeb128(const std::vector<u8>& data, std::size_t& offset) { | 146 | u64 ReadLeb128(const std::vector<u8>& data, std::size_t& offset) { |
| 147 | u32 result{}; | 147 | u64 result{}; |
| 148 | u32 shift{}; | 148 | u32 shift{}; |
| 149 | do { | 149 | |
| 150 | result |= (data[offset] & 0x7f) << shift; | 150 | for (std::size_t i = 0; i < sizeof(u64); i++) { |
| 151 | const auto v = data[offset]; | ||
| 152 | result |= (static_cast<u64>(v & 0x7f) << shift); | ||
| 151 | shift += 7; | 153 | shift += 7; |
| 152 | offset++; | 154 | offset++; |
| 153 | if (offset >= data.size()) { | 155 | if (offset >= data.size() || ((v & 0x80) == 0)) { |
| 154 | break; | 156 | break; |
| 155 | } | 157 | } |
| 156 | } while ((data[offset] & 0x80) != 0); | 158 | } |
| 157 | return result; | 159 | return result; |
| 158 | } | 160 | } |
| 159 | 161 | ||
| @@ -262,7 +264,7 @@ private: | |||
| 262 | 264 | ||
| 263 | switch (entry.severity) { | 265 | switch (entry.severity) { |
| 264 | case LogSeverity::Trace: | 266 | case LogSeverity::Trace: |
| 265 | LOG_DEBUG(Service_LM, "LogManager DEBUG ({}):\n{}", DestinationToString(destination), | 267 | LOG_DEBUG(Service_LM, "LogManager TRACE ({}):\n{}", DestinationToString(destination), |
| 266 | output_log); | 268 | output_log); |
| 267 | break; | 269 | break; |
| 268 | case LogSeverity::Info: | 270 | case LogSeverity::Info: |
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 71c7587db..b6ac0a81a 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp | |||
| @@ -65,13 +65,18 @@ static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMem | |||
| 65 | void DecryptSharedFontToTTF(const std::vector<u32>& input, std::vector<u8>& output) { | 65 | void DecryptSharedFontToTTF(const std::vector<u32>& input, std::vector<u8>& output) { |
| 66 | ASSERT_MSG(input[0] == EXPECTED_MAGIC, "Failed to derive key, unexpected magic number"); | 66 | ASSERT_MSG(input[0] == EXPECTED_MAGIC, "Failed to derive key, unexpected magic number"); |
| 67 | 67 | ||
| 68 | if (input.size() < 2) { | ||
| 69 | LOG_ERROR(Service_NS, "Input font is empty"); | ||
| 70 | return; | ||
| 71 | } | ||
| 72 | |||
| 68 | const u32 KEY = input[0] ^ EXPECTED_RESULT; // Derive key using an inverse xor | 73 | const u32 KEY = input[0] ^ EXPECTED_RESULT; // Derive key using an inverse xor |
| 69 | std::vector<u32> transformed_font(input.size()); | 74 | std::vector<u32> transformed_font(input.size()); |
| 70 | // TODO(ogniK): Figure out a better way to do this | 75 | // TODO(ogniK): Figure out a better way to do this |
| 71 | std::transform(input.begin(), input.end(), transformed_font.begin(), | 76 | std::transform(input.begin(), input.end(), transformed_font.begin(), |
| 72 | [&KEY](u32 font_data) { return Common::swap32(font_data ^ KEY); }); | 77 | [&KEY](u32 font_data) { return Common::swap32(font_data ^ KEY); }); |
| 73 | transformed_font[1] = Common::swap32(transformed_font[1]) ^ KEY; // "re-encrypt" the size | 78 | std::memcpy(output.data(), transformed_font.data() + 2, |
| 74 | std::memcpy(output.data(), transformed_font.data() + 2, transformed_font.size() * sizeof(u32)); | 79 | (transformed_font.size() - 2) * sizeof(u32)); |
| 75 | } | 80 | } |
| 76 | 81 | ||
| 77 | void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, | 82 | void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, |