diff options
author | Vaxry <[email protected]> | 2024-03-30 03:09:22 +0000 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-03-30 03:09:22 +0000 |
commit | 6fb8f502050c269597636c3b0bfcf046f7f6a947 (patch) | |
tree | bfd2e5780f1f3690b1eb5f0a7baa12af571e3d4a /hyprpm/src | |
parent | 54376d7b5f88bffd96ce9ded26637d83d7aa95b1 (diff) | |
download | Hyprland-6fb8f502050c269597636c3b0bfcf046f7f6a947.tar.gz Hyprland-6fb8f502050c269597636c3b0bfcf046f7f6a947.zip |
hyprpm: avoid crashes on corrupted headers
ref #5329
Diffstat (limited to 'hyprpm/src')
-rw-r--r-- | hyprpm/src/core/PluginManager.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp index c5926c3e..965f2e9d 100644 --- a/hyprpm/src/core/PluginManager.cpp +++ b/hyprpm/src/core/PluginManager.cpp @@ -333,7 +333,12 @@ eHeadersErrors CPluginManager::headersValid() { std::string verHeaderContent((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>())); ifs.close(); - std::string hash = verHeaderContent.substr(verHeaderContent.find("#define GIT_COMMIT_HASH") + 23); + const auto HASHPOS = verHeaderContent.find("#define GIT_COMMIT_HASH"); + + if (HASHPOS == std::string::npos || HASHPOS + 23 >= verHeaderContent.length()) + return HEADERS_CORRUPTED; + + std::string hash = verHeaderContent.substr(HASHPOS + 23); hash = hash.substr(0, hash.find_first_of('\n')); hash = hash.substr(hash.find_first_of('"') + 1); hash = hash.substr(0, hash.find_first_of('"')); |