kdecore: use QCryptographicHash::hash() to make lock name

converting the file to hex can result in way too long file name and
infinite loop in KLockFile::lock()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-09-20 12:04:51 +03:00
parent 96de1ec99f
commit 88394f1a7f

View file

@ -22,6 +22,7 @@
#include "kdebug.h"
#include "kde_file.h"
#include <QCryptographicHash>
#include <QCoreApplication>
#include <QThread>
@ -51,7 +52,7 @@ KLockFile::KLockFile(const QString &file)
: d(new KLockFilePrivate())
{
d->m_lockfile = QFile::encodeName(KGlobal::dirs()->saveLocation("tmp"));
d->m_lockfile.append(QFile::encodeName(file).toHex());
d->m_lockfile.append(QCryptographicHash::hash(QFile::encodeName(file), QCryptographicHash::KAT).toHex());
d->m_lockfile.append(".klockfile");
}