summaryrefslogtreecommitdiffstats
path: root/dmarcpipe.py
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2018-03-06 20:44:26 +0000
committerTomasz Kramkowski <tk@the-tk.com>2018-03-06 20:44:26 +0000
commitd429058e56536fc714a7370d41b6035a71b0c6d3 (patch)
tree6ffc137c5851d59255c3a4080146952f754f0cf5 /dmarcpipe.py
parent7fb0f2383264e8ae2f942613e7496072d0cefb8c (diff)
downloaddmarcpipe-master.tar.gz
dmarcpipe-master.tar.xz
dmarcpipe-master.zip
dmarcpipe.py: Fix potential for RecursionError in octet_streamHEADmaster
If an attachment of mime type 'application/octet-stream' is recognised as 'application/octet-stream' then the program would enter into an infinite loop and throw a RecursionError which likely wouldn't be too bad but it's probably clearer to give a KeyError and mark the report as invalid instead.
Diffstat (limited to 'dmarcpipe.py')
-rwxr-xr-xdmarcpipe.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/dmarcpipe.py b/dmarcpipe.py
index bbcc914..0178a1e 100755
--- a/dmarcpipe.py
+++ b/dmarcpipe.py
@@ -47,7 +47,12 @@ def zip2xml(data):
return z.open(n[0]).read()
gzip2xml = lambda data: gz_decompress(data)
-octet_stream = lambda data: decode(data, magic(data).mime_type)
+
+def octet_stream(data):
+ mime = magic(data).mime_type
+ if mime == 'application/octet-stream':
+ raise KeyError
+ return decode(data, mime)
decoders = {
'application/gzip': gzip2xml,