Changeset 259780 in webkit
- Timestamp:
- Apr 8, 2020, 9:33:27 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/persistence/PersistentCoders.h (modified) (3 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Platform/IPC/ArgumentCoders.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r259773 r259780 1 2020-04-08 David Kilzer <ddkilzer@apple.com> 2 3 WTF::Persistence::VectorCoder and IPC::VectorArgumentCoder should use checked arithmetic 4 <https://webkit.org/b/210227> 5 <rdar://problem/60832243> 6 7 Reviewed by Alex Christensen. 8 9 * wtf/persistence/PersistentCoders.h: 10 (WTF::Persistence::VectorCoder::decode): 11 - Use checked arithemtic for multiplication. 12 1 13 2020-04-08 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Source/WTF/wtf/persistence/PersistentCoders.h
r248268 r259780 1 1 /* 2 * Copyright (C) 2010 , 2014-2015Apple Inc. All rights reserved.2 * Copyright (C) 2010-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include <utility> 29 #include <wtf/CheckedArithmetic.h> 29 30 #include <wtf/Forward.h> 30 31 #include <wtf/HashMap.h> … … 171 172 temp.grow(size); 172 173 173 decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T)); 174 Checked<size_t> checkedSize(size); 175 decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), (checkedSize * sizeof(T)).unsafeGet()); 174 176 175 177 vector.swap(temp); -
trunk/Source/WebKit/ChangeLog
r259779 r259780 1 2020-04-08 David Kilzer <ddkilzer@apple.com> 2 3 WTF::Persistence::VectorCoder and IPC::VectorArgumentCoder should use checked arithmetic 4 <https://webkit.org/b/210227> 5 <rdar://problem/60832243> 6 7 Reviewed by Alex Christensen. 8 9 * Platform/IPC/ArgumentCoders.h: 10 (IPC::VectorArgumentCoder::decode): 11 - Use safeCast<> to cast from uint64_t to size_t. 12 - Use checked arithemtic for multiplication. 13 1 14 2020-04-08 Alexey Proskuryakov <ap@apple.com> 2 15 -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h
r258902 r259780 1 1 /* 2 * Copyright (C) 2010-20 17Apple Inc. All rights reserved.2 * Copyright (C) 2010-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 #include <utility> 31 31 #include <wtf/Box.h> 32 #include <wtf/CheckedArithmetic.h> 32 33 #include <wtf/Forward.h> 33 34 #include <wtf/MonotonicTime.h> … … 366 367 static bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector) 367 368 { 368 uint64_t size; 369 if (!decoder.decode(size)) 370 return false; 369 uint64_t decodedSize; 370 if (!decoder.decode(decodedSize)) 371 return false; 372 373 auto size = safeCast<size_t>(decodedSize); 371 374 372 375 // Since we know the total size of the elements, we can allocate the vector in … … 381 384 temp.grow(size); 382 385 383 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T))) { 386 Checked<size_t> checkedSize(size); 387 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), (checkedSize * sizeof(T)).unsafeGet(), alignof(T))) { 384 388 decoder.markInvalid(); 385 389 return false; … … 392 396 static Optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder) 393 397 { 394 uint64_t size; 395 if (!decoder.decode(size)) 396 return WTF::nullopt; 397 398 uint64_t decodedSize; 399 if (!decoder.decode(decodedSize)) 400 return WTF::nullopt; 401 402 auto size = safeCast<size_t>(decodedSize); 403 398 404 // Since we know the total size of the elements, we can allocate the vector in 399 405 // one fell swoop. Before allocating we must however make sure that the decoder buffer … … 407 413 vector.grow(size); 408 414 409 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(vector.data()), size * sizeof(T), alignof(T))) { 415 Checked<size_t> checkedSize(size); 416 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(vector.data()), (checkedSize * sizeof(T)).unsafeGet(), alignof(T))) { 410 417 decoder.markInvalid(); 411 418 return WTF::nullopt;
Note:
See TracChangeset
for help on using the changeset viewer.