diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-06-14 20:48:24 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-06-14 20:48:24 +0200 |
| commit | 60e10327715e420f652ed148e72e22ce8ded55a3 (patch) | |
| tree | 8ab3722ac19e31d61e85e7134ebfe4232b1bc540 /tools | |
| parent | 10713532917591445080bee19159447b683b548a (diff) | |
[qt] fix various crashes due to invalid/corrupted/outdated settings (#4070)
lots of "out of index" errors :)
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4070
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/README.md | 2 | ||||
| -rw-r--r-- | tools/fuzzsettings.cpp | 63 | ||||
| -rwxr-xr-x | tools/fuzzsettings.sh | 12 |
3 files changed, 77 insertions, 0 deletions
diff --git a/tools/README.md b/tools/README.md index 367a00f246..d4f5aa1baa 100644 --- a/tools/README.md +++ b/tools/README.md @@ -28,6 +28,8 @@ Tools for Eden and other subprojects. When adding new scripts please use `#!/bin - `clang-format.sh`: Runs `clang-format` on the entire codebase. * Requires: clang - `find-unused-strings.sh`: Find any unused strings in the Android app (XML -> Kotlin). +- `cpp-lint.sh`: Homemade dumb C++ linter. +- `fuzzsettings.cpp`: Fuzz settings files. ## Android It's recommended to run these scritps after almost any Android change, as they are relatively fast and important both for APK bloat and CI. diff --git a/tools/fuzzsettings.cpp b/tools/fuzzsettings.cpp new file mode 100644 index 0000000000..e9685ce9f4 --- /dev/null +++ b/tools/fuzzsettings.cpp @@ -0,0 +1,63 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include <cstdio> +#include <cstdlib> +#include <cctype> +#include <cstring> +#include <ctime> +#include <string> +#include <string_view> + +int main(int argc, char *argv[]) { + std::srand(unsigned(std::time(nullptr))); + + FILE *fp = std::fopen(argv[1], "rt"); + if (fp) { + char line[BUFSIZ]; + while (std::fgets(line, sizeof(line), fp)) { + if (line[0] == '[') { + std::printf("%s", line); + } else if (std::isspace(line[0])) { + std::printf("%s", line); + } else { + char *p = std::strchr(line, '='); + if (std::strstr(line, "\\default") == nullptr) { + // not default + *p = '\0'; + std::string new_line{line}; + std::string value{p + 1}; + if (value == "true" || value == "false") { + new_line += std::string{} + "=TreufLAlse857874FJJakshjryiu475" + '\n'; + } else if (std::isdigit(value[0])) { + if (new_line == "size" + || std::strstr(new_line.c_str(), "entries\\size") != nullptr + || std::strstr(new_line.c_str(), "\\size")) { + new_line += "=-1\n"; + } else { + new_line += '=' + std::to_string(int(std::rand())) + '\n'; + } + } else { + std::string_view const cset{"03832///1/1/.1/1./1./1./1.1/.1194573290uwmgjouidyhiomHMNIODASJK,POF MSHDVLJPOIuksdtpsunmghns"}; + std::string rst{"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}; + for (size_t i = 0; i < rst.size(); ++i) + rst[i] = cset[std::rand() % cset.size()]; + + //new_line += "=\"" + rst + "\""; + new_line += "=" + value; + } + std::printf("%s", new_line.c_str()); + } else { + // yes default + *p = '\0'; + std::string new_line{line}; + std::string value{p + 1}; + new_line += "=false\n"; + std::printf("%s", new_line.c_str()); + } + } + } + std::fclose(fp); + } + return 0; +} diff --git a/tools/fuzzsettings.sh b/tools/fuzzsettings.sh new file mode 100755 index 0000000000..7cf613dc3d --- /dev/null +++ b/tools/fuzzsettings.sh @@ -0,0 +1,12 @@ +#!/bin/sh -ex + +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +ROOTDIR=$(CDPATH='' cd -- "$(dirname -- "$0")/" && pwd) + +touch "$2" + +c++ "$ROOTDIR/fuzzsettings.cpp" -o fuzzsettings +./fuzzsettings "$1" >"$2" +rm fuzzsettings |
