Chromium Code Reviews| Index: device/bluetooth/bluetooth_uuid.cc |
| diff --git a/device/bluetooth/bluetooth_uuid.cc b/device/bluetooth/bluetooth_uuid.cc |
| index 714d1c5c3409ddffbe8357926e2c131fed1cff18..792515a1e69ca1e43c2371076b5b00192647b70e 100644 |
| --- a/device/bluetooth/bluetooth_uuid.cc |
| +++ b/device/bluetooth/bluetooth_uuid.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/basictypes.h" |
| #include "base/logging.h" |
| #include "base/strings/string_util.h" |
| +#include "ipc/ipc_message.h" |
| namespace device { |
| @@ -93,3 +94,27 @@ void PrintTo(const BluetoothUUID& uuid, std::ostream* out) { |
| } |
| } // namespace device |
| + |
| +void IPC::ParamTraits<device::BluetoothUUID>::Write(Message* m, |
| + const param_type& p) { |
| + m->WriteString(p.canonical_value()); |
| +} |
| + |
| +bool IPC::ParamTraits<device::BluetoothUUID>::Read(const Message* m, |
| + base::PickleIterator* iter, |
| + param_type* r) { |
| + std::string value; |
| + if (!iter->ReadString(&value)) |
| + return false; |
| + *r = device::BluetoothUUID(value); |
| + // If the format isn't 128-bit, .value() would return a different answer than |
| + // .canonical_value(). Then if browser-side code accidentally checks .value() |
| + // against a 128-bit string literal, a hostile renderer could use the 16- or |
| + // 32-bit format and evade the check. |
| + return r->format() == device::BluetoothUUID::kFormat128Bit; |
|
Jeffrey Yasskin
2015/06/15 23:48:23
Tom, is this the right way to validate IPCs that a
|
| +} |
| + |
| +void IPC::ParamTraits<device::BluetoothUUID>::Log(const param_type& p, |
| + std::string* l) { |
| + l->append(p.canonical_value()); |
| +} |