Coverage Report

Created: 2026-02-26 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwebsockets/lws_upng_inflate_fuzzer.cpp
Line
Count
Source
1
// Licensed under the Apache License, Version 2.0 (the "License");
2
// you may not use this file except in compliance with the License.
3
// You may obtain a copy of the License at
4
//
5
//      http://www.apache.org/licenses/LICENSE-2.0
6
//
7
// Unless required by applicable law or agreed to in writing, software
8
// distributed under the License is distributed on an "AS IS" BASIS,
9
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
// See the License for the specific language governing permissions and
11
// limitations under the License.
12
13
/*
14
 * This fuzzer is generated by UTopia project based on TEST(Test_Tensorflow,
15
 * read_inception). (UTopia Project: https://github.com/Samsung/UTopia)
16
 */
17
#include "libwebsockets.h"
18
#include <fuzzer/FuzzedDataProvider.h>
19
20
1.18k
static void lws_api_test_gunzip(FuzzedDataProvider &provider) {
21
1.18k
  int result = 0;
22
1.18k
  struct inflator_ctx *gunz = nullptr;
23
1.18k
  const uint8_t *outring;
24
1.18k
  size_t outringlen, *opl, *cl = 0;
25
1.18k
  auto input1 = provider.ConsumeRandomLengthString();
26
27
1.18k
  gunz = lws_upng_inflator_create(&outring, &outringlen, &opl, &cl);
28
1.18k
  if (!gunz)
29
0
    goto bail;
30
31
1.18k
  lws_upng_inflate_data(gunz, input1.c_str(), input1.size());
32
33
1.18k
bail:
34
1.18k
  if (gunz)
35
1.18k
    lws_upng_inflator_destroy(&gunz);
36
1.18k
}
37
38
1.18k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, uint32_t size) {
39
1.18k
  FuzzedDataProvider provider(data, size);
40
1.18k
  auto select = provider.ConsumeIntegralInRange<unsigned char>(0, 1);
41
1.18k
  switch (select) {
42
1.18k
  case 0:
43
1.18k
    lws_api_test_gunzip(provider);
44
1.18k
    break;
45
1.18k
  }
46
47
1.18k
  return 0;
48
1.18k
}