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 #include "phonenumbers/phonenumbermatcher.h"
16 #include <string>
17 #include <vector>
18
19 #include <unicode/unistr.h>
20
21 #include "phonenumbers/base/basictypes.h"
22 #include "phonenumbers/base/memory/scoped_ptr.h"
23 #include "phonenumbers/base/memory/singleton.h"
24 #include "phonenumbers/default_logger.h"
25 #include "phonenumbers/phonenumber.h"
26 #include "phonenumbers/phonenumber.pb.h"
27 #include "phonenumbers/phonenumbermatch.h"
28 #include "phonenumbers/phonenumberutil.h"
29 #include "phonenumbers/stringutil.h"
30
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)31 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
32 {
33 if (size < 75)
34 return 0;
35
36 std::string input(reinterpret_cast<const char*>(data), 60);
37 data += 60;
38 size -= 60;
39 std::string input2(reinterpret_cast<const char*>(data), size);
40
41 i18n::phonenumbers::PhoneNumberUtil *phone_util = i18n::phonenumbers::PhoneNumberUtil::GetInstance();
42 i18n::phonenumbers::PhoneNumber parsed;
43 phone_util->Parse(input, input2, &parsed);
44 phone_util->IsValidNumber(parsed);
45 phone_util->GetCountryCodeForRegion(input);
46
47 return 0;
48 }
49