diff --git a/fuzz/gen_unpack_pack_seeds.py b/fuzz/gen_unpack_pack_seeds.py new file mode 100644 index 000000000..7b9c26015 --- /dev/null +++ b/fuzz/gen_unpack_pack_seeds.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +"""Generate seed files for fuzz/unpack_pack_fuzzer_seed_corpus. + +The committed raw seed files in unpack_pack_fuzzer_seed_corpus/ were produced +by this script; re-run it from this directory to regenerate them. It emits a +canonical MessagePack byte sample for every format family (ints at their width +edges, floats, str/bin size encodings, arrays/maps at their 16/32 boundaries, +ext types, timestamps, deep nesting, concatenated messages) plus a few +truncated/malformed samples so the error paths are seeded too. The incumbent +seed corpus ships only five files (EmptyArray, EmptyObject, ExcessiveNesting, +OpenWeatherMap, WeatherUnderground); this widens type coverage without +duplicating those names. +""" +import os + +HERE = os.path.dirname(os.path.abspath(__file__)) +OUT = os.path.join(HERE, 'unpack_pack_fuzzer_seed_corpus') + +SEEDS = { + 'GenFixintEdges': b'\x00\x7f\xe0\xff', + 'GenNilBool': b'\xc0\xc2\xc3', + 'GenInt8Edges': b'\xd0\x80\xd0\x7f\xd0\xff\xd0\x00', + 'GenInt16Edges': b'\xd1\x80\x00\xd1\x7f\xff\xd1\xff\xff', + 'GenInt32Edges': b'\xd2\x80\x00\x00\x00\xd2\x7f\xff\xff\xff\xd2\xff\xff\xff\xff', + 'GenInt64Edges': b'\xd3\x80' + b'\x00'*6 + b'\xd3\x7f' + b'\xff'*6 + b'\xd3' + b'\xff'*8, + 'GenUintEdges': b'\xcc\xff\xcd\xff\xff\xce\xff\xff\xff\xff\xcf' + b'\xff'*8, + 'GenFloats': b'\xca\x3f\x80\x00\x00\xca\x7f\x7f\xff\xff\xcb\x40\x09\x21\xfb\x54\x44\x2d\xcb\x00\x00\x00\x00\x00\x00\x00\x01', + 'GenStrFix': b'\xa1x\xa3abc', + 'GenStrUtf8': b'\xa6' + 'caf\u00e9'.encode('utf-8') + b'\xa4' + '\U0001f600'.encode('utf-8'), + 'GenStr255': b'\xd9\xff' + b'a'*255, + 'GenStr256': b'\xda\x01\x00' + b'b'*256, + 'GenBinSizes': b'\xc4\x05' + b'\x01'*5 + b'\xc5\x01\x00' + b'\x02'*256 + b'\xc4\x00', + 'GenArrays': b'\x90\x92\x01\x02\x93\x01\x92\x02\x03\x04', + 'GenNested32': b'\x91'*32 + b'\x01', + 'GenMaps': b'\x80\x81\xa1a\x01\x82\xa1k\xa1v\xa1j\xa2vv', + 'GenExtTypes': b'\xd4\x05\x01\xd5\x06\x02\x03\xd6\x07' + b'\x04'*4 + b'\xd8\x08' + b'\x09'*16, + 'GenTimestamps': b'\xd6\xff\x00\x00\x00\x00\xd7\xff' + (b'\x01'*8) + b'\xc7\x0c\xff' + (b'\x00'*4) + (b'\x02'*8), + 'GenMultiMessage': b'\x01\xc2\x91\x02\xa1z', + 'GenTruncatedStr': b'\xd9\x05ab', + 'GenMalformedMap': b'\xde\x00\x02\xa1a\x01', + 'GenArray32Short': b'\xdd\x00\x00\x00\x01\x01', + 'GenMapStrInt': b'\x83\xa1x\x01\xa1y\x02\xa1z\x03', + 'GenMixedTree': (b'\x93\x81\xa1k\xc7\x03\x07\x01\x02\x03\x92\xd0\xfe\xcc\x2a\xcb\xbf\xf0\x00\x00\x00\x00\x00\x10\xc0'), +} + +def main(): + os.makedirs(OUT, exist_ok=True) + for name, data in SEEDS.items(): + with open(os.path.join(OUT, name), 'wb') as f: + f.write(data) + print('wrote %d seeds to %s' % (len(SEEDS), OUT)) + +if __name__ == '__main__': + main() diff --git a/fuzz/unpack_pack_fuzzer.dict b/fuzz/unpack_pack_fuzzer.dict new file mode 100644 index 000000000..6a936fa7e --- /dev/null +++ b/fuzz/unpack_pack_fuzzer.dict @@ -0,0 +1,45 @@ +nil="\xc0" +false="\xc2" +true="\xc3" +bin8="\xc4" +bin16="\xc5" +bin32="\xc6" +ext8="\xc7" +ext16="\xc8" +ext32="\xc9" +float32="\xca" +float64="\xcb" +uint8="\xcc" +uint16="\xcd" +uint32="\xce" +uint64="\xcf" +int8="\xd0" +int16="\xd1" +int32="\xd2" +int64="\xd3" +fixext1="\xd4" +fixext2="\xd5" +fixext4="\xd6" +fixext8="\xd7" +fixext16="\xd8" +str8="\xd9" +str16="\xda" +str32="\xdb" +array16="\xdc" +array32="\xdd" +map16="\xde" +map32="\xdf" +pos_fixint_min="\x00" +pos_fixint_max="\x7f" +neg_fixint_min="\xe0" +neg_fixint_max="\xff" +fixmap_min="\x80" +fixmap_max="\x8f" +fixarray_min="\x90" +fixarray_max="\x9f" +fixstr_min="\xa0" +fixstr_max="\xbf" +timestamp32="\xd6\xff" +timestamp64="\xd7\xff" +timestamp96="\xc7\x0c\xff" +never_used="\xc1" diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenArray32Short b/fuzz/unpack_pack_fuzzer_seed_corpus/GenArray32Short new file mode 100644 index 000000000..eec653fb2 Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenArray32Short differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenArrays b/fuzz/unpack_pack_fuzzer_seed_corpus/GenArrays new file mode 100644 index 000000000..f426c24a6 --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenArrays @@ -0,0 +1 @@ +’“’ \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenBinSizes b/fuzz/unpack_pack_fuzzer_seed_corpus/GenBinSizes new file mode 100644 index 000000000..c7a75abeb Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenBinSizes differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenExtTypes b/fuzz/unpack_pack_fuzzer_seed_corpus/GenExtTypes new file mode 100644 index 000000000..0b6b9677f --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenExtTypes @@ -0,0 +1 @@ +ŌÕÖŲ \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenFixintEdges b/fuzz/unpack_pack_fuzzer_seed_corpus/GenFixintEdges new file mode 100644 index 000000000..fdc28a161 Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenFixintEdges differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenFloats b/fuzz/unpack_pack_fuzzer_seed_corpus/GenFloats new file mode 100644 index 000000000..e7008f04d Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenFloats differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt16Edges b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt16Edges new file mode 100644 index 000000000..60821b6de Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt16Edges differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt32Edges b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt32Edges new file mode 100644 index 000000000..5eb93a50c Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt32Edges differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt64Edges b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt64Edges new file mode 100644 index 000000000..5d54188f1 Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt64Edges differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt8Edges b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt8Edges new file mode 100644 index 000000000..4e86e1f06 Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenInt8Edges differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenMalformedMap b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMalformedMap new file mode 100644 index 000000000..df64c08cf Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMalformedMap differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenMapStrInt b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMapStrInt new file mode 100644 index 000000000..c717962f3 --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMapStrInt @@ -0,0 +1 @@ +ƒ”x”y”z \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenMaps b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMaps new file mode 100644 index 000000000..f5557c69f --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMaps @@ -0,0 +1 @@ +€”a‚”k”v”j¢vv \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenMixedTree b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMixedTree new file mode 100644 index 000000000..279793dd4 Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMixedTree differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenMultiMessage b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMultiMessage new file mode 100644 index 000000000..307fac2bf --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenMultiMessage @@ -0,0 +1 @@ +Ā‘”z \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenNested32 b/fuzz/unpack_pack_fuzzer_seed_corpus/GenNested32 new file mode 100644 index 000000000..d8a72681d --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenNested32 @@ -0,0 +1 @@ +‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘ \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenNilBool b/fuzz/unpack_pack_fuzzer_seed_corpus/GenNilBool new file mode 100644 index 000000000..ce2fe1dcb --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenNilBool @@ -0,0 +1 @@ +ĄĀĆ \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenStr255 b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStr255 new file mode 100644 index 000000000..3962a854b --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStr255 @@ -0,0 +1 @@ +Ł’aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenStr256 b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStr256 new file mode 100644 index 000000000..00d3fe1f8 Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStr256 differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenStrFix b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStrFix new file mode 100644 index 000000000..fdfcc9dcb --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStrFix @@ -0,0 +1 @@ +”x£abc \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenStrUtf8 b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStrUtf8 new file mode 100644 index 000000000..2c9071b26 --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenStrUtf8 @@ -0,0 +1 @@ +¦cafĆ©¤šŸ˜€ \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenTimestamps b/fuzz/unpack_pack_fuzzer_seed_corpus/GenTimestamps new file mode 100644 index 000000000..64ae12b37 Binary files /dev/null and b/fuzz/unpack_pack_fuzzer_seed_corpus/GenTimestamps differ diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenTruncatedStr b/fuzz/unpack_pack_fuzzer_seed_corpus/GenTruncatedStr new file mode 100644 index 000000000..e155fc020 --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenTruncatedStr @@ -0,0 +1 @@ +Łab \ No newline at end of file diff --git a/fuzz/unpack_pack_fuzzer_seed_corpus/GenUintEdges b/fuzz/unpack_pack_fuzzer_seed_corpus/GenUintEdges new file mode 100644 index 000000000..b05d03467 --- /dev/null +++ b/fuzz/unpack_pack_fuzzer_seed_corpus/GenUintEdges @@ -0,0 +1 @@ +Ģ’Ķ’’Ī’’’’Ļ’’’’’’’’ \ No newline at end of file