aboutsummaryrefslogtreecommitdiff
path: root/projects/libpng-proto
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2019-01-11 16:00:03 -0800
committerKostya Serebryany <kcc@google.com>2019-01-11 16:00:03 -0800
commit83585a0190b5fc9e76fcf4be996787c44b7c7ca1 (patch)
tree2cefd6a4f8038f3558076be63c31d8b05a5ed020 /projects/libpng-proto
parentb41592118ef76b7a0af7c543c0cd13125049e5a1 (diff)
downloadoss-fuzz-83585a0190b5fc9e76fcf4be996787c44b7c7ca1.tar.gz
[libpng-proto] extend the example proto fuzz target with explicit support for iCCP PNG chunk
Diffstat (limited to 'projects/libpng-proto')
-rw-r--r--projects/libpng-proto/png_fuzz_proto.proto6
-rw-r--r--projects/libpng-proto/png_proto_fuzzer_example.cc8
2 files changed, 14 insertions, 0 deletions
diff --git a/projects/libpng-proto/png_fuzz_proto.proto b/projects/libpng-proto/png_fuzz_proto.proto
index d978978f7..ca9a18e3b 100644
--- a/projects/libpng-proto/png_fuzz_proto.proto
+++ b/projects/libpng-proto/png_fuzz_proto.proto
@@ -17,6 +17,11 @@ message IDAT {
required bytes data = 1;
}
+message iCCP {
+ required string name = 1;
+ required bytes data = 2;
+}
+
message OtherChunk {
oneof type {
uint32 known_type = 1;
@@ -29,6 +34,7 @@ message PngChunk {
oneof chunk {
PLTE plte = 1;
IDAT idat = 2;
+ iCCP iccp = 3;
OtherChunk other_chunk = 10000;
}
}
diff --git a/projects/libpng-proto/png_proto_fuzzer_example.cc b/projects/libpng-proto/png_proto_fuzzer_example.cc
index 66ee18a68..e2957f7c1 100644
--- a/projects/libpng-proto/png_proto_fuzzer_example.cc
+++ b/projects/libpng-proto/png_proto_fuzzer_example.cc
@@ -68,6 +68,14 @@ std::string ProtoToPng(const PngProto &png_proto) {
WriteChunk(all, "PLTE", chunk.plte().data());
} else if (chunk.has_idat()) {
WriteChunk(all, "IDAT", chunk.idat().data(), true);
+ } else if (chunk.has_iccp()) {
+ std::stringstream iccp_str;
+ iccp_str << chunk.iccp().name();
+ WriteByte(iccp_str, 0);
+ WriteByte(iccp_str, 0);
+ auto compressed_data = Compress(chunk.iccp().data());
+ iccp_str.write(compressed_data.data(), compressed_data.size());
+ WriteChunk(all, "iCCP", iccp_str.str());
} else if (chunk.has_other_chunk()) {
auto &other_chunk = chunk.other_chunk();
char type[5] = {0};