From ea87b8454ce340477a0b08d08c6cc5982ad1a4e2 Mon Sep 17 00:00:00 2001 From: Yue-Lan Date: Thu, 7 Dec 2023 11:19:14 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20#204782=20=E3=80=90KVE=E3=80=91peony-ex?= =?UTF-8?q?tensions=20KVE-2023-1201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- peony-share/service/samba-config.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/peony-share/service/samba-config.cpp b/peony-share/service/samba-config.cpp index 6ef505b..3334cef 100644 --- a/peony-share/service/samba-config.cpp +++ b/peony-share/service/samba-config.cpp @@ -28,6 +28,8 @@ #include #include +#include + class SambaConfigPrivate { public: @@ -334,6 +336,20 @@ bool SambaConfig::init(QString name, int pid, int uid) return false; } + // KVE-2023-1201 + if (name.contains("|")) + return false; + QStringList allUsers; + struct passwd *pw; + setpwent(); + while ((pw = getpwent()) != nullptr) { + allUsers << pw->pw_name; + } + endpwent(); + if (!allUsers.contains(name)) { + return false; + } + if (d->mLock.tryLock(300)) { d->mUserName = name; d->mUserPid = pid;