# HG changeset patch # User Augie Fackler # Date 2018-04-29 04:29:40 # Node ID 99ab72b867b7552de7426665d6bd4564d8e071c9 # Parent 06e2fc08f6f02332f1f5ec2895875b852fdfc124 fuzz: try and generate an interesting mpatch seed from a repo Differential Revision: https://phab.mercurial-scm.org/D3697 diff --git a/contrib/fuzz/mpatch_corpus.py b/contrib/fuzz/mpatch_corpus.py --- a/contrib/fuzz/mpatch_corpus.py +++ b/contrib/fuzz/mpatch_corpus.py @@ -1,9 +1,14 @@ -from __future__ import absolute_import +from __future__ import absolute_import, print_function import argparse import struct import zipfile +from mercurial import ( + hg, + ui as uimod, +) + ap = argparse.ArgumentParser() ap.add_argument("out", metavar="some.zip", type=str, nargs=1) args = ap.parse_args() @@ -59,6 +64,16 @@ with zipfile.ZipFile(args.out[0], "w", z str(corpus('a', [delta([deltafrag(0, 20, 'b')])])) ) + try: + # Generated from repo data + r = hg.repository(uimod.ui(), '../..') + fl = r.file('mercurial/manifest.py') + rl = getattr(fl, '_revlog', fl) + bins = rl._chunks(rl._deltachain(10)[0]) + zf.writestr('manifest_py_rev_10', + str(corpus(bins[0], bins[1:]))) + except: # skip this, so no re-raises + print('skipping seed file from repo data') # Automatically discovered by running the fuzzer zf.writestr( "mpatch_decode_old_overread", "\x02\x00\x00\x00\x02\x00\x00\x00"