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:
parent
aa95c3cbf5
commit
ef64a0ef4c
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user