Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(771)

Unified Diff: device/u2f/u2f_message_fuzzer.cc

Issue 2771673002: Use vectors instead of IOBuffer for U2fPackets (Closed)
Patch Set: Use memcpy instead of looping. Update fuzzer with new APIs. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/u2f/u2f_message.cc ('k') | device/u2f/u2f_message_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « device/u2f/u2f_message.cc ('k') | device/u2f/u2f_message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698