Patchwork D3697: fuzz: try and generate an interesting mpatch seed from a repo

login
register
mail settings
Submitter phabricator
Date June 8, 2018, 2:29 p.m.
Message ID <4a0bda7dcc168a9af8ba514be39ca957@localhost.localdomain>
Download mbox | patch
Permalink /patch/32027/
State Not Applicable
Headers show

Comments

phabricator - June 8, 2018, 2:29 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG99ab72b867b7: fuzz: try and generate an interesting mpatch seed from a repo (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3697?vs=8988&id=8998

REVISION DETAIL
  https://phab.mercurial-scm.org/D3697

AFFECTED FILES
  contrib/fuzz/mpatch_corpus.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

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 @@ 
         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"