The conditions were in reverse order (maybe someone was reading the
PowerPC manual and forgot about IBM's bit numbering), and additionally
the two conditions for unsigned comparison were wrong.
Fixes https://bugs.dolphin-emu.org/issues/14054.
Reported by MrSynAckster. A specifically crafted NAND dump could use
path traversal to overwrite files on the host file system.
This is also an accuracy fix for importing NAND dumps that contain
file names that Dolphin is supposed to escape. Some games' save files
are affected.
GetPath has two special cases where it doesn't add a slash.
The first is for the root entry's special name "/". The next commit will
be neater if we can skip calling GetPath for the root entry, because '/'
is one of the characters that Common::EscapeFileName replaces with an
escape sequence. Let's check for entry number 0 instead.
The second is for parent paths that already end in a slash. There's no
actual need to check for this - double slashes are harmless, and for
comparison, NANDImporter::ExtractCertificates already appends slashes
without checking if there already is one. Let's remove this check.
For some reason, NativeLibrary.kt calling Log for the alert message text
makes Dolphin die with a JNI error. Supposedly the jstring passed to the
logging function is invalid. I don't understand why, because the dialog
that we show right afterwards is able to read the string just fine. The
error happens even if I pass the string directly to Log without
prepending any extra text.
There's no real downside to having the logging in C++ instead of Kotlin,
so let's move it to C++ to avoid the JNI error.
When calling `ShowMessageAlert` with a given `MsgType`, log the alert
with a `LogLevel` matching the `MsgType` instead of always using
`LogLevel::LERROR`.
SendGameStatus() was writing SyncIdentifierComparison as a u32 but the server reads it as a u8 enum, so the server always gets 0 (SameGame). This bug was introduced in commit 66276ac.
Remove the [[maybe_unused]] annotation from various parameters that are
unconditionally unused and comment out their names instead. This makes
it unambiguous that the variables are unused, while making the remaining
[[maybe_unused]] annotations more reliable indicators that those
variables are in fact used in some contexts.
These parameters are mostly in overridden functions where the override
doesn't need that particular variable.
Make `s_is_adapter_wanted` and the elements of `s_config_rumble_enabled`
atomic.
The CPU thread reads `s_is_adapter_wanted` and `s_config_rumble_enabled`
in `Output`, while the host thread writes to them in `RefreshConfig`.
The simplest way to trigger this race is to close the `Settings` window
while playing a game with the adapter active.