From c27616fc32ab918e6dd5e0fb763f1d9bddc960f9 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 29 Nov 2020 15:52:53 -0600 Subject: [PATCH] fuzz jpg --- tests/fuzz_jpg.nim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/fuzz_jpg.nim diff --git a/tests/fuzz_jpg.nim b/tests/fuzz_jpg.nim new file mode 100644 index 0000000..da83af2 --- /dev/null +++ b/tests/fuzz_jpg.nim @@ -0,0 +1,17 @@ +import random, strformat, pixie/fileformats/jpg, pixie/common + +randomize() + +let original = cast[seq[uint8]](readFile("tests/images/jpg/jpeg420exif.jpg")) + +for i in 0 ..< 10_000: + var data = original + let + pos = rand(data.len) + value = rand(255).uint8 + data[pos] = value + echo &"{i} {pos} {value}" + try: + discard decodeJpg(data) + except PixieError: + discard