• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device 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 "cubic_bezier_fuzzer.h"
17 #include "camera_timer.h"
18 #include "hstream_capture.h"
19 #include "message_parcel.h"
20 #include "nativetoken_kit.h"
21 #include "token_setproc.h"
22 #include "accesstoken_kit.h"
23 #include "camera_metadata_info.h"
24 #include "metadata_utils.h"
25 #include "test_token.h"
26 
27 namespace {
28 
29 const int32_t LIMITSIZE = 12;
30 
31 }
32 
33 namespace OHOS {
34 namespace CameraStandard {
35 
36 std::shared_ptr<CubicBezier> CubicBezierFuzzer::fuzz_{nullptr};
37 
Test(uint8_t * rawData,size_t size)38 void CubicBezierFuzzer::Test(uint8_t *rawData, size_t size)
39 {
40     if (rawData == nullptr || size < LIMITSIZE) {
41         return;
42     }
43     CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "GetPermission error");
44 
45     fuzz_ = std::make_shared<CubicBezier>();
46     CHECK_RETURN_ELOG(!fuzz_, "Create fuzz_ Error");
47     MessageParcel data;
48     data.WriteRawData(rawData, size);
49 
50     data.RewindRead(0);
51     float currentZoom = data.ReadFloat();
52     float targetZoom = data.ReadFloat();
53     float frameInterval = data.ReadFloat();
54     fuzz_->GetZoomArray(currentZoom, targetZoom, frameInterval);
55 }
56 
57 } // namespace CameraStandard
58 } // namespace OHOS
59 
60 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(uint8_t * data,size_t size)61 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size)
62 {
63     /* Run your code on data */
64     OHOS::CameraStandard::CubicBezierFuzzer::Test(data, size);
65     return 0;
66 }