diff options
-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('"')); |