1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Check that dropped files are readable&non-sequential

Fixes #934

No, you're not allowed to send /dev/urandom to your friends. Ever.
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-01-19 00:22:40 +01:00
parent aa95c3cbf5
commit ef64a0ef4c
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -727,6 +727,20 @@ void ChatForm::dropEvent(QDropEvent *ev)
{
QFileInfo info(url.path());
QFile file(info.absoluteFilePath());
if (!file.exists() || !file.open(QIODevice::ReadOnly))
{
QMessageBox::warning(this, tr("File not read"), tr("qTox wasn't able to open %1").arg(info.fileName()));
continue;
}
if (file.isSequential())
{
QMessageBox::critical(0, tr("Bad Idea"), tr("You're trying to send a special (sequential) file, that's not going to work!"));
file.close();
continue;
}
file.close();
if (info.exists())
Core::getInstance()->sendFile(f->getFriendID(), info.fileName(), info.absoluteFilePath(), info.size());
}