Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f1eb43e

Browse files
Zepeng HuSkia Commit-Bot
authored andcommitted
replace max_len with if statements
Change-Id: I60d60e9b9ea0b7b6544a36bef7f4e263bb9de532 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/296416 Reviewed-by: Kevin Lubick <[email protected]> Commit-Queue: Zepeng Hu <[email protected]>
1 parent 4569f66 commit f1eb43e

28 files changed

+82
-1
lines changed

fuzz/oss_fuzz/FuzzAPIImageFilter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
void fuzz_ImageFilter(Fuzz* f);
1111

1212
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
13+
if (size > 4000) {
14+
return 0;
15+
}
1316
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
1417
fuzz_ImageFilter(&fuzz);
1518
return 0;

fuzz/oss_fuzz/FuzzAPISkDescriptor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ void fuzz_SkDescriptor(Fuzz* f);
1111

1212
#if defined(IS_FUZZING_WITH_LIBFUZZER)
1313
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
14+
if (size > 4000) {
15+
return 0;
16+
}
1417
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
1518
fuzz_SkDescriptor(&fuzz);
1619
return 0;

fuzz/oss_fuzz/FuzzAndroidCodec.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ bool FuzzAndroidCodec(sk_sp<SkData> bytes, uint8_t sampleSize) {
5252

5353
#if defined(IS_FUZZING_WITH_LIBFUZZER)
5454
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
55+
if (size > 10240) {
56+
return 0;
57+
}
5558
auto bytes = SkData::MakeWithoutCopy(data, size);
5659
Fuzz fuzz(bytes);
5760
uint8_t sampleSize;

fuzz/oss_fuzz/FuzzAnimatedImage.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ bool FuzzAnimatedImage(sk_sp<SkData> bytes) {
3838

3939
#if defined(IS_FUZZING_WITH_LIBFUZZER)
4040
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
41+
if (size > 10240) {
42+
return 0;
43+
}
4144
auto bytes = SkData::MakeWithoutCopy(data, size);
4245
FuzzAnimatedImage(bytes);
4346
return 0;

fuzz/oss_fuzz/FuzzDrawFunctions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
void fuzz_DrawFunctions(Fuzz* f);
1111

1212
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
13+
if (size > 4000) {
14+
return 0;
15+
}
1316
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
1417
fuzz_DrawFunctions(&fuzz);
1518
return 0;

fuzz/oss_fuzz/FuzzGradients.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
void fuzz_Gradients(Fuzz* f);
1111

1212
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
13+
if (size > 4000) {
14+
return 0;
15+
}
1316
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
1417
fuzz_Gradients(&fuzz);
1518
return 0;

fuzz/oss_fuzz/FuzzImage.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ bool FuzzImageDecode(sk_sp<SkData> bytes) {
3030

3131
#if defined(IS_FUZZING_WITH_LIBFUZZER)
3232
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
33+
if (size > 10240) {
34+
return 0;
35+
}
3336
auto bytes = SkData::MakeWithoutCopy(data, size);
3437
FuzzImageDecode(bytes);
3538
return 0;

fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ void FuzzImageFilterDeserialize(sk_sp<SkData> bytes) {
4141

4242
#if defined(IS_FUZZING_WITH_LIBFUZZER)
4343
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
44+
if (size > 10024) {
45+
return 0;
46+
}
4447
gSkFontMgr_DefaultFactory = &ToolUtils::MakePortableFontMgr;
4548
auto bytes = SkData::MakeWithoutCopy(data, size);
4649
FuzzImageFilterDeserialize(bytes);

fuzz/oss_fuzz/FuzzIncrementalImage.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ bool FuzzIncrementalImageDecode(sk_sp<SkData> bytes) {
4747

4848
#if defined(IS_FUZZING_WITH_LIBFUZZER)
4949
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
50+
if (size > 10240) {
51+
return 0;
52+
}
5053
auto bytes = SkData::MakeWithoutCopy(data, size);
5154
FuzzIncrementalImageDecode(bytes);
5255
return 0;

fuzz/oss_fuzz/FuzzJPEGEncoder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
void fuzz_JPEGEncoder(Fuzz* f);
1111

1212
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
13+
if (size > 262150) {
14+
return 0;
15+
}
1316
auto fuzz = Fuzz(SkData::MakeWithoutCopy(data, size));
1417
fuzz_JPEGEncoder(&fuzz);
1518
return 0;

0 commit comments

Comments
 (0)