OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/system/transport_data.h" | 5 #include "mojo/system/transport_data.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 size_t size = handle_table[i].size; | 290 size_t size = handle_table[i].size; |
291 if (size > kMaxSerializedDispatcherSize || size > buffer_size) | 291 if (size > kMaxSerializedDispatcherSize || size > buffer_size) |
292 return kInvalidSerializedDispatcher; | 292 return kInvalidSerializedDispatcher; |
293 | 293 |
294 // Note: This is an overflow-safe check for |offset + size > buffer_size| | 294 // Note: This is an overflow-safe check for |offset + size > buffer_size| |
295 // (we know that |size <= buffer_size| from the previous check). | 295 // (we know that |size <= buffer_size| from the previous check). |
296 if (offset > buffer_size - size) | 296 if (offset > buffer_size - size) |
297 return kInvalidSerializedDispatcher; | 297 return kInvalidSerializedDispatcher; |
298 } | 298 } |
299 | 299 |
300 return NULL; | 300 return nullptr; |
301 } | 301 } |
302 | 302 |
303 // static | 303 // static |
304 void TransportData::GetPlatformHandleTable(const void* transport_data_buffer, | 304 void TransportData::GetPlatformHandleTable(const void* transport_data_buffer, |
305 size_t* num_platform_handles, | 305 size_t* num_platform_handles, |
306 const void** platform_handle_table) { | 306 const void** platform_handle_table) { |
307 DCHECK(transport_data_buffer); | 307 DCHECK(transport_data_buffer); |
308 DCHECK(num_platform_handles); | 308 DCHECK(num_platform_handles); |
309 DCHECK(platform_handle_table); | 309 DCHECK(platform_handle_table); |
310 | 310 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 const void* source = static_cast<const char*>(buffer) + offset; | 342 const void* source = static_cast<const char*>(buffer) + offset; |
343 (*dispatchers)[i] = Dispatcher::TransportDataAccess::Deserialize( | 343 (*dispatchers)[i] = Dispatcher::TransportDataAccess::Deserialize( |
344 channel, handle_table[i].type, source, size, platform_handles.get()); | 344 channel, handle_table[i].type, source, size, platform_handles.get()); |
345 } | 345 } |
346 | 346 |
347 return dispatchers.Pass(); | 347 return dispatchers.Pass(); |
348 } | 348 } |
349 | 349 |
350 } // namespace system | 350 } // namespace system |
351 } // namespace mojo | 351 } // namespace mojo |
OLD | NEW |