From a7820e5f089c8079bbe42cd863e6ad334a7743d4 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 3 Jan 2010 13:00:16 +0000 Subject: [PATCH] - Make sure the torrent file is valid before loading it --- src/bittorrent.cpp | 2 ++ src/torrentadditiondlg.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index d53988654..b6f39d962 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -857,6 +857,8 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr try { // Getting torrent file informations t = new torrent_info(file.toLocal8Bit().data()); + if(!t->is_valid()) + throw std::exception(); } catch(std::exception&) { if(!from_url.isNull()) { addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red")); diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index e46405d8e..20f382eef 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -158,6 +158,8 @@ public: // Getting torrent file informations try { t = new torrent_info(filePath.toLocal8Bit().data()); + if(!t->is_valid()) + throw std::exception(); } catch(std::exception&) { qDebug("Caught error loading torrent"); if(!from_url.isNull()){