Index: device/u2f/u2f_message_fuzzer.cc |
diff --git a/device/u2f/u2f_message_fuzzer.cc b/device/u2f/u2f_message_fuzzer.cc |
index 2d0c0d8cfaf8790fc60ae1cc69bc5600d20b0d15..cafa83cdea48d6173f4f67446e86a9fa0a898c33 100644 |
--- a/device/u2f/u2f_message_fuzzer.cc |
+++ b/device/u2f/u2f_message_fuzzer.cc |
@@ -5,6 +5,7 @@ |
#include <stddef.h> |
#include <stdint.h> |
#include <algorithm> |
+#include <vector> |
#include "net/base/io_buffer.h" |
#include "u2f_message.h" |
@@ -13,9 +14,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
size_t remaining_buffer = size; |
uint8_t* start = const_cast<uint8_t*>(data); |
Reilly Grant (use Gerrit)
2017/03/23 18:39:54
Looking at this now I can't figure out why this ne
Casey Piper
2017/03/23 18:48:05
The compiler is requiring it in this case. Granted
Casey Piper
2017/03/23 20:15:29
Done.
|
- scoped_refptr<net::IOBufferWithSize> buf( |
- new net::IOBufferWithSize(packet_size)); |
- memcpy(buf->data(), start, std::min(packet_size, remaining_buffer)); |
+ std::vector<uint8_t> buf(start, |
+ start + std::min(packet_size, remaining_buffer)); |
std::unique_ptr<device::U2fMessage> msg = |
device::U2fMessage::CreateFromSerializedData(buf); |
@@ -24,9 +24,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
while (remaining_buffer > 0) { |
size_t buffer_size = std::min(packet_size, remaining_buffer); |
- scoped_refptr<net::IOBufferWithSize> tmp_buf( |
- new net::IOBufferWithSize(buffer_size)); |
- memcpy(tmp_buf->data(), start, buffer_size); |
+ std::vector<uint8_t> tmp_buf(start, start + buffer_size); |
msg->AddContinuationPacket(tmp_buf); |
remaining_buffer -= std::min(remaining_buffer, buffer_size); |
start += buffer_size; |