Coverage Report

Created: 2026-03-08 06:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/string_escape_fuzzer.cc
Line
Count
Source
1
// Copyright 2020 Google Inc.
2
//
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
17
#include <string> 
18
19
#include "absl/strings/escaping.h"
20
21
717
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
22
717
  std::string str (reinterpret_cast<const char*>(data), size);
23
717
  std::string escaped, unescaped;
24
717
  escaped = absl::CHexEscape(str);
25
717
  absl::CUnescape(escaped, &unescaped);
26
717
  if (str != unescaped)
27
0
    abort();
28
29
717
  escaped = absl::CEscape(str);
30
717
  absl::CUnescape(escaped, &unescaped);
31
717
  if (str != unescaped)
32
0
    abort();
33
34
717
  escaped = absl::Utf8SafeCEscape(str);
35
717
  absl::CUnescape(escaped, &unescaped);
36
717
  if (str != unescaped)
37
0
    abort();
38
  
39
717
  escaped = absl::Utf8SafeCHexEscape(str);
40
717
  absl::CUnescape(escaped, &unescaped);
41
717
  if (str != unescaped)
42
0
    abort();
43
  
44
717
  std::string encoded, decoded;
45
717
  absl::Base64Escape(str, &encoded);
46
717
  absl::Base64Unescape(encoded, &decoded);
47
717
  if (str != unescaped)
48
0
    abort();
49
50
717
  absl::WebSafeBase64Escape(str, &encoded);
51
717
  absl::WebSafeBase64Unescape(encoded, &decoded);
52
717
  if (str != decoded)
53
0
    abort();
54
55
717
  std::string hex_result, bytes_result;
56
717
  hex_result = absl::BytesToHexString(str);
57
717
  bytes_result = absl::HexStringToBytes(hex_result);
58
717
  if (str != decoded)
59
0
    abort();
60
61
717
  return 0;
62
717
}