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

Side by Side Diff: base/pickle.cc

Issue 1008393004: Revert of Revert of MSan: check data is initialized when serializing with base::Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « base/compiler_specific.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/pickle.h" 5 #include "base/pickle.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> // for max() 9 #include <algorithm> // for max()
10 10
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 WriteBytesCommon(data, length); 346 WriteBytesCommon(data, length);
347 } 347 }
348 348
349 template void Pickle::WriteBytesStatic<2>(const void* data); 349 template void Pickle::WriteBytesStatic<2>(const void* data);
350 template void Pickle::WriteBytesStatic<4>(const void* data); 350 template void Pickle::WriteBytesStatic<4>(const void* data);
351 template void Pickle::WriteBytesStatic<8>(const void* data); 351 template void Pickle::WriteBytesStatic<8>(const void* data);
352 352
353 inline void Pickle::WriteBytesCommon(const void* data, size_t length) { 353 inline void Pickle::WriteBytesCommon(const void* data, size_t length) {
354 DCHECK_NE(kCapacityReadOnly, capacity_after_header_) 354 DCHECK_NE(kCapacityReadOnly, capacity_after_header_)
355 << "oops: pickle is readonly"; 355 << "oops: pickle is readonly";
356 MSAN_CHECK_MEM_IS_INITIALIZED(data, length);
356 size_t data_len = AlignInt(length, sizeof(uint32)); 357 size_t data_len = AlignInt(length, sizeof(uint32));
357 DCHECK_GE(data_len, length); 358 DCHECK_GE(data_len, length);
358 #ifdef ARCH_CPU_64_BITS 359 #ifdef ARCH_CPU_64_BITS
359 DCHECK_LE(data_len, kuint32max); 360 DCHECK_LE(data_len, kuint32max);
360 #endif 361 #endif
361 DCHECK_LE(write_offset_, kuint32max - data_len); 362 DCHECK_LE(write_offset_, kuint32max - data_len);
362 size_t new_size = write_offset_ + data_len; 363 size_t new_size = write_offset_ + data_len;
363 if (new_size > capacity_after_header_) { 364 if (new_size > capacity_after_header_) {
364 Resize(std::max(capacity_after_header_ * 2, new_size)); 365 Resize(std::max(capacity_after_header_ * 2, new_size));
365 } 366 }
366 367
367 char* write = mutable_payload() + write_offset_; 368 char* write = mutable_payload() + write_offset_;
368 memcpy(write, data, length); 369 memcpy(write, data, length);
369 memset(write + length, 0, data_len - length); 370 memset(write + length, 0, data_len - length);
370 header_->payload_size = static_cast<uint32>(new_size); 371 header_->payload_size = static_cast<uint32>(new_size);
371 write_offset_ = new_size; 372 write_offset_ = new_size;
372 } 373 }
OLDNEW
« no previous file with comments | « base/compiler_specific.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698