Skip to content

Commit

Permalink
replace max_len with if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepeng Hu committed Jun 14, 2020
1 parent abd7476 commit 5b35f21
Show file tree
Hide file tree
Showing 26 changed files with 76 additions and 1 deletion.
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzAPIImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_ImageFilter(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_ImageFilter(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzAPISkDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ void fuzz_SkDescriptor(Fuzz* f);

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_SkDescriptor(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzAndroidCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ bool FuzzAndroidCodec(sk_sp<SkData> bytes, uint8_t sampleSize) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 10240) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
Fuzz fuzz(bytes);
uint8_t sampleSize;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzAnimatedImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ bool FuzzAnimatedImage(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 10240) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzAnimatedImage(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzDrawFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_DrawFunctions(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_DrawFunctions(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzGradients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_Gradients(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_Gradients(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ bool FuzzImageDecode(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 10240) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzImageDecode(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzIncrementalImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ bool FuzzIncrementalImageDecode(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 10240) {
return size;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzIncrementalImageDecode(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzJPEGEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_JPEGEncoder(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 262150) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_JPEGEncoder(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzMockGPUCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ extern "C" {
}

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_MockGPUCanvas(&fuzz);
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzNullCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
void fuzz_NullCanvas(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_NullCanvas(&fuzz);
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzPNGEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_PNGEncoder(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 262150) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_PNGEncoder(&fuzz);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion fuzz/oss_fuzz/FuzzPathDeserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void FuzzPathDeserialize(SkReadBuffer& buf) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < 4) {
if (size < 4 || size > 2000) {
return 0;
}
uint32_t packed;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzPathMeasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_PathMeasure(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_PathMeasure(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzPathop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_Pathop(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_Pathop(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzPolyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_PolyUtils(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_PolyUtils(&fuzz);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzRasterN32Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
void fuzz_RasterN32Canvas(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 4000) {
return 0;
}
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_RasterN32Canvas(&fuzz);
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzRegionDeserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ bool FuzzRegionDeserialize(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 512) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzRegionDeserialize(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzRegionSetPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ void FuzzRegionSetPath(Fuzz* fuzz) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 512) {
return 0;
}
sk_sp<SkData> bytes(SkData::MakeWithoutCopy(data, size));
Fuzz fuzz(bytes);
FuzzRegionSetPath(&fuzz);
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ bool FuzzSKSL2GLSL(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 3000) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzSKSL2GLSL(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzSKSL2Metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ bool FuzzSKSL2Metal(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 3000) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzSKSL2Metal(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ bool FuzzSKSL2Pipeline(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 3000) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzSKSL2Pipeline(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ bool FuzzSKSL2SPIRV(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 3000) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzSKSL2SPIRV(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzSkDescriptorDeserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ void FuzzSkDescriptorDeserialize(sk_sp<SkData> bytes) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 1024) {
return 0;
}
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzSkDescriptorDeserialize(bytes);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ void FuzzTextBlobDeserialize(SkReadBuffer& buf) {

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 1024) {
return 0;
}
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
SkReadBuffer buf(data, size);
FuzzTextBlobDeserialize(buf);
Expand Down
3 changes: 3 additions & 0 deletions fuzz/oss_fuzz/FuzzWEBPEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
void fuzz_WEBPEncoder(Fuzz* f);

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size > 262150) {
return 0;
}
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
fuzz_WEBPEncoder(&fuzz);
return 0;
Expand Down

0 comments on commit 5b35f21

Please sign in to comment.