Chromium Code Reviews| Index: device/u2f/u2f_message.cc |
| diff --git a/device/u2f/u2f_message.cc b/device/u2f/u2f_message.cc |
| index 8cf2281ef24504e9ab54280a9c78550b066a0ca1..8259147ba761d53fc97e5d8d56d313e390b7a7ad 100644 |
| --- a/device/u2f/u2f_message.cc |
| +++ b/device/u2f/u2f_message.cc |
| @@ -30,8 +30,9 @@ std::unique_ptr<U2fMessage> U2fMessage::CreateFromSerializedData( |
| static_cast<size_t>(buf->size()) < kInitPacketHeader) |
| return nullptr; |
| + std::vector<uint8_t> init_data(buf->data(), buf->data() + buf->size()); |
|
Reilly Grant (use Gerrit)
2017/03/22 23:08:16
This method should take a const std::vector<uint8_
Casey Piper
2017/03/23 03:47:24
Done.
|
| std::unique_ptr<U2fInitPacket> init_packet = |
| - U2fInitPacket::CreateFromSerializedData(buf, &remaining_size); |
| + U2fInitPacket::CreateFromSerializedData(init_data, &remaining_size); |
| if (init_packet == nullptr) |
| return nullptr; |
| @@ -95,10 +96,12 @@ 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(); |
| + std::vector<uint8_t> data = packets_.front()->GetSerializedData(); |
|
Reilly Grant (use Gerrit)
2017/03/22 23:08:17
If GetSerializedData() will be building this vecto
Casey Piper
2017/03/23 03:47:24
Done.
|
| + auto buffer = make_scoped_refptr(new net::IOBufferWithSize(data.size())); |
| + memcpy(buffer->data(), data.data(), data.size()); |
| + |
| packets_.pop_front(); |
| - return buf; |
| + return buffer; |
| } |
| return nullptr; |
| } |
| @@ -106,8 +109,10 @@ scoped_refptr<net::IOBufferWithSize> U2fMessage::PopNextPacket() { |
| bool U2fMessage::AddContinuationPacket( |
| scoped_refptr<net::IOBufferWithSize> buf) { |
| size_t remaining_size = remaining_size_; |
| + std::vector<uint8_t> cont_data(buf->data(), buf->data() + buf->size()); |
| std::unique_ptr<U2fContinuationPacket> cont_packet = |
| - U2fContinuationPacket::CreateFromSerializedData(buf, &remaining_size); |
| + U2fContinuationPacket::CreateFromSerializedData(cont_data, |
| + &remaining_size); |
| // Reject packets with a different channel id |
| if (cont_packet == nullptr || channel_id_ != cont_packet->channel_id()) |