replace max_len with if statements

This commit is contained in:
Zepeng Hu 2020-06-14 19:03:34 +00:00
parent abd7476916
commit 5b35f212ac
26 changed files with 76 additions and 1 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;