From 9df5a8903776168ece79dc39597f572e32d82cd3 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Mon, 8 Jun 2015 22:40:55 +0200 Subject: [PATCH] Don't crash when trying to save to a FIFO or other special file When giving the path to a FIFO or other special file qutebrowser would completely hang, and has to be killed. Tested: - Asks for overwrite: file, symlink to file - Saves in dir: dir, symlink to dir - Aborts: block dev, char dev, fifo, socket, and a symlink to all of these --- qutebrowser/browser/downloads.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index aa29fce9c..acb8edb35 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -446,6 +446,13 @@ class DownloadItem(QObject): # The file already exists, so ask the user if it should be # overwritten. self._ask_overwrite_question() + # FIFO, device node, etc. Don't even try. + elif (os.path.exists(self._filename) and not + os.path.isdir(self._filename)): + self.cancel(False) + message.error(self._win_id, "The file {} already exists, and is a " + "special file. Aborting.".format( + self._filename)) else: self._create_fileobj()