summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-10-27 14:55:20 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-10-27 14:55:20 -0400
commitaaa5789ba792a3b268effbf4beaae4c93525b0dc (patch)
tree338319dad71d463140cd87d82978403fd557d198
parent1b4913f371f5296292abbc608d0bbfe172cb6739 (diff)
downloadb4-aaa5789ba792a3b268effbf4beaae4c93525b0dc.tar.gz
Fix a crasher discovered in testing
Don't crash on incomplete threads when trying to carry over previous trailers. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py10
-rw-r--r--b4/mbox.py2
2 files changed, 8 insertions, 4 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index 7e38e13..2a8bcb8 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -304,10 +304,11 @@ class LoreMailbox:
# previous revisions to current revision if patch/metadata did
# not change
pmsg.load_hashes()
- attid = pmsg.attestation.attid
- if attid not in self.trailer_map:
- self.trailer_map[attid] = list()
- self.trailer_map[attid] += trailers
+ if pmsg.attestation:
+ attid = pmsg.attestation.attid
+ if attid not in self.trailer_map:
+ self.trailer_map[attid] = list()
+ self.trailer_map[attid] += trailers
pmsg.followup_trailers += trailers
break
if not pmsg.reply:
@@ -2035,6 +2036,7 @@ def get_pi_thread_by_msgid(msgid, savefile, useproject=None, nocache=False):
tmp_mbox = mkstemp('b4-lookup-mbox')[1]
in_mbxf = get_pi_thread_by_url(t_mbx_url, tmp_mbox, nocache=nocache)
if not in_mbxf:
+ os.unlink(tmp_mbox)
return None
in_mbx = mailbox.mbox(in_mbxf)
out_mbx = mailbox.mbox(savefile)
diff --git a/b4/mbox.py b/b4/mbox.py
index 2ec74c9..a49624c 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -494,12 +494,14 @@ def main(cmdargs):
threadmbox = b4.get_pi_thread_by_msgid(msgid, savefile, useproject=cmdargs.useproject, nocache=cmdargs.nocache)
if threadmbox is None:
+ os.unlink(savefile)
return
else:
if os.path.exists(cmdargs.localmbox):
threadmbox = cmdargs.localmbox
else:
logger.critical('Mailbox %s does not exist', cmdargs.localmbox)
+ os.unlink(savefile)
sys.exit(1)
if threadmbox and cmdargs.checknewer: