Coverage Report

Created: 2026-01-16 06:50

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
708
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
22
708
  std::string str (reinterpret_cast<const char*>(data), size);
23
708
  std::string escaped, unescaped;
24
708
  escaped = absl::CHexEscape(str);
25
708
  absl::CUnescape(escaped, &unescaped);
26
708
  if (str != unescaped)
27
0
    abort();
28
29
708
  escaped = absl::CEscape(str);
30
708
  absl::CUnescape(escaped, &unescaped);
31
708
  if (str != unescaped)
32
0
    abort();
33
34
708
  escaped = absl::Utf8SafeCEscape(str);
35
708
  absl::CUnescape(escaped, &unescaped);
36
708
  if (str != unescaped)
37
0
    abort();
38
  
39
708
  escaped = absl::Utf8SafeCHexEscape(str);
40
708
  absl::CUnescape(escaped, &unescaped);
41
708
  if (str != unescaped)
42
0
    abort();
43
  
44
708
  std::string encoded, decoded;
45
708
  absl::Base64Escape(str, &encoded);
46
708
  absl::Base64Unescape(encoded, &decoded);
47
708
  if (str != unescaped)
48
0
    abort();
49
50
708
  absl::WebSafeBase64Escape(str, &encoded);
51
708
  absl::WebSafeBase64Unescape(encoded, &decoded);
52
708
  if (str != decoded)
53
0
    abort();
54
55
708
  std::string hex_result, bytes_result;
56
708
  hex_result = absl::BytesToHexString(str);
57
708
  bytes_result = absl::HexStringToBytes(hex_result);
58
708
  if (str != decoded)
59
0
    abort();
60
61
708
  return 0;
62
708
}