1 // Copyright 2016 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifdef UNSAFE_BUFFERS_BUILD 6 // TODO(crbug.com/351564777): Remove this and convert code to safer constructs. 7 #pragma allow_unsafe_buffers 8 #endif 9 10 #include <stddef.h> 11 #include <stdint.h> 12 13 #include <string> 14 15 #include "base/third_party/nspr/prtime.h" 16 17 PRTime parsed_time; 18 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)19extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 20 if (size < 1) 21 return 0; 22 23 const uint8_t selector = data[0]; 24 25 // Using std::string instead of a (potentially faster) fixed buffer to catch 26 // accesses beyond the end of the string. 27 std::string str(reinterpret_cast<const char*>(data+1), size - 1); 28 PR_ParseTimeString(str.c_str(), selector & 1, &parsed_time); 29 30 return 0; 31 } 32