[PATCH patchbot] patchbot: do not crash for malicious mails without message-id

Augie Fackler raf at durin42.com
Thu Nov 17 20:58:55 EST 2016


> On Nov 16, 2016, at 10:16 PM, Jun Wu <quark at fb.com> wrote:
> 
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1479352538 0
> #      Thu Nov 17 03:15:38 2016 +0000
> # Node ID 7ecfbdf2460df04c1c263875a12403d3cfe3134a
> # Parent  9036c3d03d301378e67d4516937ea9c6672c3c67
> patchbot: do not crash for malicious mails without message-id

Queued for patchbot, thanks

> 
> Sometimes due to power failure, the on-disk files could get truncated and
> lose message-id. Currently patchbot would raise "KeyError: message-id" but
> it does not print clues about which mail is corrupted.
> 
> This patch makes it print which mail does not contain message-id and just
> ignore them.
> 
> diff --git a/index.py b/index.py
> --- a/index.py
> +++ b/index.py
> @@ -51,4 +51,7 @@ def index_mailbox(session, mb):
>             if key not in all_keys:
>                 mail = mb[key]
> +                if 'message-id' not in mail:
> +                    sys.stderr.write('%s: ignored - no message-id\n' % key)
> +                    continue
>                 if session.query(models.Message).filter(models.Message.id.is_(
>                         mail['message-id'])).count() > 0:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20161117/e42a4795/attachment.sig>


More information about the Mercurial-devel mailing list