Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <stddef.h> | |
| 6 #include <stdint.h> | |
| 7 #include "u2f_message.h" | |
| 8 | |
| 9 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
| 10 size_t packet_size = 65; | |
| 11 size_t remaining_buffer = size; | |
| 12 uint8_t* start = const_cast<uint8_t*>(data); | |
| 13 | |
| 14 scoped_refptr<net::IOBufferWithSize> buf( | |
| 15 new net::IOBufferWithSize(packet_size)); | |
| 16 memcpy(buf->data(), start, std::min(packet_size, remaining_buffer)); | |
| 17 scoped_refptr<device::U2fMessage> msg = | |
| 18 device::U2fMessage::CreateFromSerializedData(buf); | |
| 19 | |
| 20 remaining_buffer -= std::min(remaining_buffer, packet_size); | |
| 21 | |
| 22 while (remaining_buffer > packet_size) { | |
|
Reilly Grant (use Gerrit)
2016/12/10 01:52:02
This means we never test a short packet.
Casey Piper
2016/12/12 18:01:42
Updated to use a small packet at the end of the bu
| |
| 23 start += packet_size; | |
| 24 memcpy(buf->data(), start, packet_size); | |
|
Reilly Grant (use Gerrit)
2016/12/10 01:52:02
Allocate a new buffer each time so that ASAN can c
Casey Piper
2016/12/12 18:01:42
Done.
| |
| 25 msg->AddContinuationPacket(buf); | |
| 26 remaining_buffer -= std::min(remaining_buffer, packet_size); | |
| 27 } | |
| 28 | |
| 29 return 0; | |
| 30 } | |
| OLD | NEW |