diff options
| author | Vaxry <vaxry@vaxry.net> | 2026-03-01 20:57:24 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2026-03-01 21:55:12 +0000 |
| commit | 5c370c3333aa6648c014a550c8b64f7f90c3f777 (patch) | |
| tree | 02c219a735fda11370fc2f45247eb4a5456b7f60 | |
| parent | cf0d256c130a80519597a92f2455ed1866bbef7e (diff) | |
hyprpm: fix url sanitization in add
this could've been used to exec additional commands with hyprpm
| -rw-r--r-- | hyprpm/src/core/PluginManager.cpp | 21 | ||||
| -rw-r--r-- | hyprpm/src/core/PluginManager.hpp | 1 | ||||
| -rw-r--r-- | src/protocols/Screencopy.cpp | 2 |
3 files changed, 17 insertions, 7 deletions
diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp index 7ffb3120..6621a49f 100644 --- a/hyprpm/src/core/PluginManager.cpp +++ b/hyprpm/src/core/PluginManager.cpp @@ -131,9 +131,18 @@ bool CPluginManager::createSafeDirectory(const std::string& path) { return true; } +bool CPluginManager::validArg(const std::string& s) { + return !s.contains("'") && !s.ends_with("\\") && !s.starts_with("\\"); +} + bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& rev) { const auto HLVER = getHyprlandVersion(); + if (!validArg(url) || !validArg(rev)) { + std::println(stderr, "\n{}", failureString("url or rev invalid")); + return false; + } + if (!hasDeps()) { std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. Dependencies not satisfied. Hyprpm requires: cmake, cpio, pkg-config, git, g++, gcc")); return false; @@ -198,7 +207,7 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& progress.printMessageAbove(infoString("Cloning {}", url)); - std::string ret = execAndGet(std::format("cd {} && git clone --recursive {} {}", getTempRoot(), url, USERNAME)); + std::string ret = execAndGet(std::format("cd {} && git clone --recursive '{}' {}", getTempRoot(), url, USERNAME)); if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) { std::println(stderr, "\n{}", failureString("Could not clone the plugin repository. shell returned:\n{}", ret)); @@ -503,11 +512,11 @@ bool CPluginManager::updateHeaders(bool force) { progress.printMessageAbove(verboseString("will shallow since: {}", SHALLOW_DATE)); std::string ret = - execAndGet(std::format("cd {} && git clone --recursive {} hyprland-{}{}", getTempRoot(), HL_URL, USERNAME, (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : ""))); + execAndGet(std::format("cd {} && git clone --recursive '{}' hyprland-{}{}", getTempRoot(), HL_URL, USERNAME, (bShallow ? " --shallow-since='" + SHALLOW_DATE + "'" : ""))); if (!std::filesystem::exists(WORKINGDIR)) { progress.printMessageAbove(failureString("Clone failed. Retrying without shallow.")); - ret = execAndGet(std::format("cd {} && git clone --recursive {} hyprland-{}", getTempRoot(), HL_URL, USERNAME)); + ret = execAndGet(std::format("cd {} && git clone --recursive '{}' hyprland-{}", getTempRoot(), HL_URL, USERNAME)); } if (!std::filesystem::exists(WORKINGDIR + "/.git")) { @@ -648,7 +657,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) { const auto HLVER = getHyprlandVersion(false); CProgressBar progress; - progress.m_iMaxSteps = REPOS.size() * 2 + 2; + progress.m_iMaxSteps = (REPOS.size() * 2) + 2; progress.m_iSteps = 0; progress.m_szCurrentMessage = "Updating repositories"; progress.print(); @@ -669,7 +678,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) { progress.printMessageAbove(infoString("Cloning {}", repo.url)); - std::string ret = execAndGet(std::format("cd {} && git clone --recursive {} {}", getTempRoot(), repo.url, USERNAME)); + std::string ret = execAndGet(std::format("cd {} && git clone --recursive '{}' {}", getTempRoot(), repo.url, USERNAME)); if (!std::filesystem::exists(m_szWorkingPluginDirectory + "/.git")) { std::println("{}", failureString("could not clone repo: shell returned: {}", ret)); @@ -679,7 +688,7 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) { if (!repo.rev.empty()) { progress.printMessageAbove(infoString("Plugin has revision set, resetting: {}", repo.rev)); - std::string ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " reset --hard --recurse-submodules " + repo.rev); + std::string ret = execAndGet("git -C " + m_szWorkingPluginDirectory + " reset --hard --recurse-submodules \'" + repo.rev + "\'"); if (ret.compare(0, 6, "fatal:") == 0) { std::println(stderr, "\n{}", failureString("could not check out revision {}: shell returned:\n{}", repo.rev, ret)); diff --git a/hyprpm/src/core/PluginManager.hpp b/hyprpm/src/core/PluginManager.hpp index 4bbbc5ca..25878f54 100644 --- a/hyprpm/src/core/PluginManager.hpp +++ b/hyprpm/src/core/PluginManager.hpp @@ -81,6 +81,7 @@ class CPluginManager { private: std::string headerError(const eHeadersErrors err); std::string headerErrorShort(const eHeadersErrors err); + bool validArg(const std::string& s); std::expected<std::string, std::string> nixDevelopIfNeeded(const std::string& cmd, const SHyprlandVersion& ver); diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 9d30be51..5cc884de 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -94,7 +94,7 @@ CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, WP<CScr return; } - const auto stride = NFormatUtils::minStride(PSHMINFO, bufSize.x); + const auto stride = NFormatUtils::minStride(PSHMINFO, bufSize.x); m_resource->sendBuffer(NFormatUtils::drmToShm(format), bufSize.x, bufSize.y, stride); if (m_resource->version() >= 3) { |
