Skip to content

Commit

Permalink
Add new fuzz-qrcode-setup-payload-parsing with dictionary and corpus
Browse files Browse the repository at this point in the history
Dictionary and corpus extracted from unit tetss.
NOTE: Corpus is *not* yet minimized.
  • Loading branch information
zcduthie committed Apr 24, 2024
1 parent 7d57a67 commit db3ad52
Show file tree
Hide file tree
Showing 24 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
"${chip_root}/src/lib/core/tests:fuzz-tlv-reader",
"${chip_root}/src/lib/dnssd/minimal_mdns/tests:fuzz-minmdns-packet-parsing",
"${chip_root}/src/lib/format/tests:fuzz-payload-decoder",
"${chip_root}/src/setup_payload/tests:fuzz-qrcode-setup-payload-parsing",
]
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MT:ABC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MT:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
H:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ASMT:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MT:M5L90MP500K64J00000
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Z%MT:ABC%
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Z%MT:ABC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%Z%MT:ABC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%Z%MT:ABC%
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%Z%MT:ABC%DDD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MT:ABC%DDD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MT:ABC%
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%MT:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%MT:%
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A%
Original file line number Diff line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15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T1VFSK1S3DO1ZTZR1UNMJ1DK5N1K8SQ1RYCU1--ZL15PKP1CD5T11UXS0%Z
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%MT:ABC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Z%MT:M5L90MP500K64J00000%Z
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ABC
55 changes: 55 additions & 0 deletions integrations/fuzz/fuzz-qrcode-setup-payload-parsing.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"MT:"
"%"
"*"
"-"
"--"
"1518"
"153000120A00D00561E77A68A9FD975057375B9283A818"
"153000FF0A001998AB7130E38B7E9A401CFE9F7B79AF18"
"153000130A00191998AB7130E38B7E9A401CFE9F7B79AF18"
"153000110A001998AB7130E38B7E9A401CFE9F7B7918"
"0A00D00561E77A68A9FD975057375B9283A8"
"0A001998AB7130E38B7E9A401CFE9F7B79"
"15300012FFFF8BEA0C775F001981365D6362E1C0665A18"
"76553581916553565535"
"A0"
"OT10"
"-N.B0"
"OT100"
"Y6V91"
"KL0B1"
"Q-M08"
"Z0"
"R600"
"81000"
"R6"
"NE71"
"PLS18"
"KKHF3W2S013OPM3EJX11"
"0\\001"
"\\0010"
"[0"
"0["
" 0"
"!0"
"\"0"
"#0"
"$0"
"%0"
"&0"
"'0"
"(0"
")0"
"*0"
"+0"
",0"
";0"
"<0"
"=0"
">0"
"@0"
"S6"
"S600"
"OE71"
"OE710"
"QLS18"
12 changes: 12 additions & 0 deletions src/setup_payload/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("//build_overrides/nlunit_test.gni")
import("//build_overrides/pigweed.gni")

import("${chip_root}/build/chip/chip_test_suite.gni")
import("${chip_root}/build/chip/fuzz_test.gni")

chip_test_suite("tests") {
output_name = "libSetupPayloadTests"
Expand Down Expand Up @@ -56,3 +57,14 @@ chip_test_suite_using_nltest("tests_nltest") {
"${nlunit_test_root}:nlunit-test",
]
}

if (enable_fuzz_test_targets) {
chip_fuzz_target("fuzz-qrcode-setup-payload-parsing") {
sources = [ "FuzzQRCodeSetupPayloadParsing.cpp" ]
public_deps = [
"${chip_root}/src/lib/support:testing",
"${chip_root}/src/platform",
"${chip_root}/src/setup_payload",
]
}
}
18 changes: 18 additions & 0 deletions src/setup_payload/tests/FuzzQRCodeSetupPayloadParsing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <cstdint>
#include <iostream>

#include "setup_payload/Base38Decode.h"
#include "setup_payload/QRCodeSetupPayloadParser.h"

using namespace chip;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t * data, size_t len)
{
chip::Platform::MemoryInit();

std::string s((const char *) data, len);
SetupPayload payload;
QRCodeSetupPayloadParser(s).populatePayload(payload);

return 0;
}

0 comments on commit db3ad52

Please sign in to comment.