From 46bd7808625543bb42d1c1f20ff5599b837d1ca8 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 9 Feb 2012 12:09:40 +1300 Subject: [PATCH] Gracefully handle invalid data format passed to -r flag. --- libmproxy/console/__init__.py | 5 ++++- libmproxy/dump.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 608742a40..76968ae5b 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -640,7 +640,10 @@ class ConsoleMaster(flow.FlowMaster): fr = flow.FlowReader(f) except IOError, v: return v.strerror - flow.FlowMaster.load_flows(self, fr) + try: + flow.FlowMaster.load_flows(self, fr) + except flow.FlowReadError, v: + return v.strerror f.close() if self.conn_list_view: self.sync_list_view() diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 2ad88cfcc..d71aed42b 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -103,7 +103,10 @@ class DumpMaster(flow.FlowMaster): freader = flow.FlowReader(f) except IOError, v: raise DumpError(v.strerror) - self.load_flows(freader) + try: + self.load_flows(freader) + except flow.FlowReadError, v: + raise DumpError(v) def _readflow(self, path):