Skip to content

Commit f097116

Browse files
dengzhongyuan365-devLiHua000
authored andcommitted
fix: add path traversal check in mkTempDir function
- Implemented a validation check in the mkTempDir function to reject infix values containing "..", enhancing security against path traversal vulnerabilities. This change improves the robustness of the temporary directory creation process.
1 parent 0a2c5e4 commit f097116

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

basestruct/utils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,14 @@ bool Utils::kernelSupportFS(const QString &fsType)
661661

662662
QString Utils::mkTempDir(const QString &infix)
663663
{
664+
qDebug() << "Utils::mkTempDir - Creating temp dir with infix:" << infix;
665+
666+
// 路径遍历检查:拒绝包含 ".." 的 infix
667+
if (infix.contains("..")) {
668+
qWarning() << "Utils::mkTempDir - Invalid infix contains path traversal:" << infix;
669+
return QString();
670+
}
671+
664672
// Construct template like "/var/tmp/diskmanager-XXXXXX" or "/var/tmp/diskmanager-INFIX-XXXXXX"
665673
QString dirTemplate = "/var/tmp/";
666674

0 commit comments

Comments
 (0)