Browse Source

Check that dropped files are readable&non-sequential

Fixes #934

No, you're not allowed to send /dev/urandom to your friends. Ever.
pull/1024/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
ef64a0ef4c
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 14
      src/widget/form/chatform.cpp

14
src/widget/form/chatform.cpp

@ -727,6 +727,20 @@ void ChatForm::dropEvent(QDropEvent *ev) @@ -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…
Cancel
Save