• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong DID Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "imagegetcapability_fuzzer.h"
17 #include <hdf_log.h>
18 #include <vector>
19 #include "v1_0/icodec_image.h"
20 using namespace OHOS::HDI::Codec::Image::V1_0;
21 using namespace OHOS;
22 using namespace std;
23 namespace OHOS {
24 namespace Codec {
25 namespace Image {
GetCapabilityList(const uint8_t * data,size_t size)26 bool GetCapabilityList(const uint8_t *data, size_t size)
27 {
28     if (data == nullptr) {
29         return false;
30     }
31 
32     sptr<ICodecImage> image = ICodecImage::Get(false);
33     if (image == nullptr) {
34         HDF_LOGE("%{public}s: get ICodecImage failed\n", __func__);
35         return false;
36     }
37 
38     vector<CodecImageCapability> caps;
39     auto err = image->GetImageCapability(caps);
40     if (err != HDF_SUCCESS) {
41         HDF_LOGE("%{public}s GetImageCapability return %{public}d", __func__, err);
42     }
43     return true;
44 }
45 }  // namespace Image
46 }  // namespace Codec
47 }  // namespace OHOS
48 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)49 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
50 {
51     OHOS::Codec::Image::GetCapabilityList(data, size);
52     return 0;
53 }
54