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

Unified Diff: device/u2f/u2f_message.cc

Issue 2771673002: Use vectors instead of IOBuffer for U2fPackets (Closed)
Patch Set: Modify fuzzer 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.h ('k') | device/u2f/u2f_message_fuzzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/u2f/u2f_message.cc
diff --git a/device/u2f/u2f_message.cc b/device/u2f/u2f_message.cc
index 8cf2281ef24504e9ab54280a9c78550b066a0ca1..0778025470c93f8b487147c4d2c1f9b5ddc9885d 100644
--- a/device/u2f/u2f_message.cc
+++ b/device/u2f/u2f_message.cc
@@ -23,11 +23,9 @@ std::unique_ptr<U2fMessage> U2fMessage::Create(
// static
std::unique_ptr<U2fMessage> U2fMessage::CreateFromSerializedData(
- scoped_refptr<net::IOBufferWithSize> buf) {
+ const std::vector<uint8_t>& buf) {
size_t remaining_size = 0;
- if (buf == nullptr ||
- static_cast<size_t>(buf->size()) > U2fPacket::kPacketSize ||
- static_cast<size_t>(buf->size()) < kInitPacketHeader)
+ if (buf.size() > U2fPacket::kPacketSize || buf.size() < kInitPacketHeader)
return nullptr;
std::unique_ptr<U2fInitPacket> init_packet =
@@ -95,16 +93,16 @@ std::list<std::unique_ptr<U2fPacket>>::const_iterator U2fMessage::end() {
scoped_refptr<net::IOBufferWithSize> U2fMessage::PopNextPacket() {
if (NumPackets() > 0) {
- scoped_refptr<net::IOBufferWithSize> buf =
- packets_.front()->GetSerializedBuffer();
+ scoped_refptr<net::IOBufferWithSize> data =
+ packets_.front()->GetSerializedData();
+
packets_.pop_front();
- return buf;
+ return data;
}
return nullptr;
}
-bool U2fMessage::AddContinuationPacket(
- scoped_refptr<net::IOBufferWithSize> buf) {
+bool U2fMessage::AddContinuationPacket(const std::vector<uint8_t>& buf) {
size_t remaining_size = remaining_size_;
std::unique_ptr<U2fContinuationPacket> cont_packet =
U2fContinuationPacket::CreateFromSerializedData(buf, &remaining_size);
« no previous file with comments | « device/u2f/u2f_message.h ('k') | device/u2f/u2f_message_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698