!17376 修改fuzz告警

Merge pull request !17376 from lemon/mymaster1122-1
This commit is contained in:
openharmony_ci 2024-11-22 06:30:44 +00:00 committed by Gitee
commit 90d38b17b4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
17 changed files with 10 additions and 569 deletions

View File

@ -16,10 +16,7 @@ group("fuzztest") {
deps = [
"convert_fuzzer:fuzztest",
"fontcollection_fuzzer:fuzztest",
"linetypography_fuzzer:fuzztest",
"textlinebase_fuzzer:fuzztest",
"typography_fuzzer:fuzztest",
"typographycreate_fuzzer:fuzztest",
]
}

View File

@ -29,7 +29,9 @@ void OHDrawingConvert1(const uint8_t* data, size_t size)
if (data == nullptr) {
return;
}
g_data = data;
g_size = size;
g_pos = 0;
std::shared_ptr<OHOS::Rosen::FontCollection> fontCollection = OHOS::Rosen::FontCollection::Create();
std::shared_ptr<OHOS::Rosen::AdapterTxt::FontCollection> adapterFontCollection =
AdapterTxt::Convert(fontCollection);
@ -58,10 +60,13 @@ void OHDrawingConvert1(const uint8_t* data, size_t size)
void OHDrawingConvert2(const uint8_t* data, size_t size)
{
uint32_t red = static_cast<float>(data[0]);
uint32_t gree = static_cast<float>(data[1]);
uint32_t blue = static_cast<float>(data[0]);
uint32_t alpha = static_cast<float>(data[1]);
g_data = data;
g_size = size;
g_pos = 0;
uint32_t red = GetObject<uint32_t>();
uint32_t gree = GetObject<uint32_t>();
uint32_t blue = GetObject<uint32_t>();
uint32_t alpha = GetObject<uint32_t>();
TextStyle textStyle;
textStyle.symbol.SetVisualMode(VisualMode(GetObject<int>() % DATA_MAX_ENUM_SIZE2));
textStyle.fontFeatures.SetFeature("tag", GetObject<int>());

View File

@ -1,74 +0,0 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
import("$graphic_2d_root/rosen/modules/2d_engine/rosen_text/config.gni")
module_out_path = "graphic_2d/graphic_2d/modules/2d_engine/adapter/skia_txt"
##############################fuzztest##########################################
ohos_fuzztest("FontCollectionFuzzTest") {
module_out_path = module_out_path
fuzz_config_file = "$graphic_2d_root/rosen/test/2d_engine/fuzztest/adapter/skia_txt/fontcollection_fuzzer"
include_dirs = [
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_test",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt/impl",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter/common",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter/skia_txt",
"$graphic_2d_root/rosen/modules/render_service_base/include",
"$graphic_2d_root/rosen/test/2d_graphics/fuzztest",
"$graphic_2d_root/rosen/test/2d_engine/fuzztest/adapter/skia_txt/fontcollection_fuzzer",
]
sources = [ "fontcollection_fuzzer.cpp" ]
platform = current_os
if (platform == "mingw") {
platform = "windows"
}
cflags = [
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
defines = [
"USE_ROSEN_DRAWING",
"USE_SKIA_TXT",
"RS_ENABLE_GPU",
]
deps = [
"$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics",
"$rosen_root/modules/2d_engine/rosen_text/skia_txt:skia_libtxt_$platform",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
part_name = "graphic_2d"
subsystem_name = "graphic"
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":FontCollectionFuzzTest" ]
}
###############################################################################

View File

@ -1,14 +0,0 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUZZ

View File

@ -1,67 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "fontcollection_fuzzer.h"
#include <cstddef>
#include <memory>
#include "font_collection.h"
#include "get_object.h"
namespace OHOS {
namespace Rosen {
namespace Drawing {
void OHDrawingFontcollectionFuzz1(const uint8_t* data, size_t size)
{
std::shared_ptr<OHOS::Rosen::FontCollection> fontCollection = OHOS::Rosen::FontCollection::Create();
fontCollection->DisableFallback();
fontCollection->DisableSystemFont();
const uint8_t* LoadFontData = nullptr;
std::shared_ptr<OHOS::Rosen::Drawing::Typeface> typeface = fontCollection->LoadFont("familyname", LoadFontData, 0);
typeface = fontCollection->LoadThemeFont("familynametest", LoadFontData, 0);
std::shared_ptr<Drawing::FontMgr> fontMgr = fontCollection->GetFontMgr();
}
void OHDrawingFontcollectionFuzz2(const uint8_t* data, size_t size)
{
std::shared_ptr<OHOS::Rosen::FontCollection> fontCollection = OHOS::Rosen::FontCollection::From(nullptr);
std::shared_ptr<OHOS::Rosen::Drawing::Typeface> typeface1 = OHOS::Rosen::Drawing::Typeface::MakeDefault();
OHOS::Rosen::Drawing::Typeface::RegisterCallBackFunc(
[](std::shared_ptr<OHOS::Rosen::Drawing::Typeface> typeface) { return false; });
fontCollection->RegisterTypeface(typeface1);
OHOS::Rosen::Drawing::Typeface::RegisterCallBackFunc(
[](std::shared_ptr<OHOS::Rosen::Drawing::Typeface> typeface) { return typeface != nullptr; });
fontCollection->RegisterTypeface(typeface1);
fontCollection->RegisterTypeface(nullptr);
}
void OHDrawingFontcollectionFuzz3(const uint8_t* data, size_t size)
{
std::shared_ptr<OHOS::Rosen::FontCollection> fontCollection = OHOS::Rosen::FontCollection::From(nullptr);
fontCollection->ClearCaches();
std::shared_ptr<Drawing::FontMgr> fontMgr = fontCollection->GetFontMgr();
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::Rosen::Drawing::OHDrawingFontcollectionFuzz1(data, size);
OHOS::Rosen::Drawing::OHDrawingFontcollectionFuzz2(data, size);
OHOS::Rosen::Drawing::OHDrawingFontcollectionFuzz3(data, size);
return 0;
}

View File

@ -1,29 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_FONTCOLLECTION_FUZZER_H
#define TEST_FONTCOLLECTION_FUZZER_H
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#define FUZZ_PROJECT_NAME "fontcollection_fuzzer"
constexpr inline size_t DATA_MAX_ENUM_SIZE1 = 3;
constexpr inline size_t DATA_MAX_ENUM_SIZE2 = 4;
constexpr inline size_t DATA_MAX_ENUM_SIZE3 = 7;
#endif // TEST_FONTCOLLECTION_FUZZER_H

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -1,76 +0,0 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
import("$graphic_2d_root/rosen/modules/2d_engine/rosen_text/config.gni")
module_out_path = "graphic_2d/graphic_2d/modules/2d_engine/adapter/skia_txt"
##############################fuzztest##########################################
ohos_fuzztest("TypographyFuzzTest") {
module_out_path = module_out_path
fuzz_config_file = "$graphic_2d_root/rosen/test/2d_engine/fuzztest/adapter/skia_txt/typography_fuzzer"
include_dirs = [
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_test",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt/txt",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt/impl",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter/common",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter/skia_txt",
"$graphic_2d_root/rosen/modules/render_service_base/include",
"$graphic_2d_root/rosen/test/2d_graphics/fuzztest",
"$graphic_2d_root/rosen/test/2d_engine/fuzztest/adapter/skia_txt/typography_fuzzer",
]
sources = [ "typography_fuzzer.cpp" ]
platform = current_os
if (platform == "mingw") {
platform = "windows"
}
cflags = [
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
defines = [
"USE_ROSEN_DRAWING",
"USE_SKIA_TXT",
"RS_ENABLE_GPU",
]
deps = [
"$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics",
"$rosen_root/modules/2d_engine/rosen_text/skia_txt:skia_libtxt_$platform",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
part_name = "graphic_2d"
subsystem_name = "graphic"
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":TypographyFuzzTest" ]
}
###############################################################################

View File

@ -1,14 +0,0 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUZZ

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "typography_fuzzer.h"
#include <cstddef>
#include "get_object.h"
namespace OHOS {
namespace Rosen {
namespace SPText {
} // namespace SPText
} // namespace Rosen
} // namespace OHOS
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
return 0;
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_TYPOGRAPHY_FUZZER_H
#define TEST_TYPOGRAPHY_FUZZER_H
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#define FUZZ_PROJECT_NAME "typography_fuzzer"
#endif // TEST_TYPOGRAPHY_FUZZER_H

View File

@ -1,76 +0,0 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/test.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")
import("$graphic_2d_root/rosen/modules/2d_engine/rosen_text/config.gni")
module_out_path = "graphic_2d/graphic_2d/modules/2d_engine/adapter/skia_txt"
##############################fuzztest##########################################
ohos_fuzztest("TypographyCreateFuzzTest") {
module_out_path = module_out_path
fuzz_config_file = "$graphic_2d_root/rosen/test/2d_engine/fuzztest/adapter/skia_txt/typographycreate_fuzzer"
include_dirs = [
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/export/rosen_test",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt/txt",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/skia_txt/impl",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter/common",
"$graphic_2d_root/rosen/modules/2d_engine/rosen_text/adapter/skia_txt",
"$graphic_2d_root/rosen/modules/render_service_base/include",
"$graphic_2d_root/rosen/test/2d_graphics/fuzztest",
"$graphic_2d_root/rosen/test/2d_engine/fuzztest/adapter/skia_txt/typographycreate_fuzzer",
]
sources = [ "typography_create_fuzzer.cpp" ]
platform = current_os
if (platform == "mingw") {
platform = "windows"
}
cflags = [
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
defines = [
"USE_ROSEN_DRAWING",
"USE_SKIA_TXT",
"RS_ENABLE_GPU",
]
deps = [
"$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics",
"$rosen_root/modules/2d_engine/rosen_text/skia_txt:skia_libtxt_$platform",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
]
part_name = "graphic_2d"
subsystem_name = "graphic"
}
###############################################################################
group("fuzztest") {
testonly = true
deps = [ ":TypographyCreateFuzzTest" ]
}
###############################################################################

View File

@ -1,14 +0,0 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUZZ

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "typography_create_fuzzer.h"
#include <cstddef>
#include "get_object.h"
namespace OHOS {
namespace Rosen {
namespace SPText {
} // namespace SPText
} // namespace Rosen
} // namespace OHOS
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
return 0;
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_TYPOGRAPHY_CREATE_FUZZER_H
#define TEST_TYPOGRAPHY_CREATE_FUZZER_H
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#define FUZZ_PROJECT_NAME "typographycreate_fuzzer"
#endif // TEST_TYPOGRAPHY_CREATE_FUZZER_H