Changeset 259788 in webkit
- Timestamp:
- Apr 9, 2020, 3:52:52 AM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/persistence/PersistentCoders.h (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Platform/IPC/ArgumentCoders.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r259786 r259788 1 2020-04-09 David Kilzer <ddkilzer@apple.com> 2 3 Follow-up: WTF::Persistence::VectorCoder and IPC::VectorArgumentCoder should do bounds checking without crashing 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 - Replace safeCast<size_t> with isInBounds<size_t> so that we 12 don't crash if `decodedSize` is too big. Instead we fail 13 decoding by returning early. 14 - Revert checked arithemtic for multiplication since 15 bufferIsLargeEnoughToContain<T(size) already did this check 16 for us. 17 1 18 2020-04-09 Mark Lam <mark.lam@apple.com> 2 19 -
trunk/Source/WTF/wtf/persistence/PersistentCoders.h
r259780 r259788 161 161 return false; 162 162 163 auto size = safeCast<size_t>(decodedSize); 163 if (!isInBounds<size_t>(decodedSize)) 164 return false; 165 166 auto size = static_cast<size_t>(decodedSize); 164 167 165 168 // Since we know the total size of the elements, we can allocate the vector in … … 172 175 temp.grow(size); 173 176 174 Checked<size_t> checkedSize(size); 175 decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), (checkedSize * sizeof(T)).unsafeGet()); 177 decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T)); 176 178 177 179 vector.swap(temp); -
trunk/Source/WebKit/ChangeLog
r259780 r259788 1 2020-04-09 David Kilzer <ddkilzer@apple.com> 2 3 Follow-up: WTF::Persistence::VectorCoder and IPC::VectorArgumentCoder should do bounds checking without crashing 4 <https://webkit.org/b/210227> 5 <rdar://problem/60832243> 6 7 Reviewed by Alex Christensen. 8 9 * Platform/IPC/ArgumentCoders.h: 10 - Add missing call to decoder.markInvalid() if decoding of 11 `decodedSize` fails. 12 - Replace safeCast<size_t> with isInBounds<size_t> so that we 13 don't crash if `decodedSize` is too big. Instead we fail 14 decoding by marking the decoder invalid and returning early. 15 - Revert checked arithemtic for multiplication since 16 bufferIsLargeEnoughToContain<T(size) already did this check 17 for us. 18 1 19 2020-04-08 David Kilzer <ddkilzer@apple.com> 2 20 -
trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h
r259780 r259788 368 368 { 369 369 uint64_t decodedSize; 370 if (!decoder.decode(decodedSize)) 371 return false; 372 373 auto size = safeCast<size_t>(decodedSize); 370 if (!decoder.decode(decodedSize)) { 371 decoder.markInvalid(); 372 return false; 373 } 374 375 if (!WTF::isInBounds<size_t>(decodedSize)) { 376 decoder.markInvalid(); 377 return false; 378 } 379 380 auto size = static_cast<size_t>(decodedSize); 374 381 375 382 // Since we know the total size of the elements, we can allocate the vector in … … 384 391 temp.grow(size); 385 392 386 Checked<size_t> checkedSize(size); 387 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), (checkedSize * sizeof(T)).unsafeGet(), alignof(T))) { 393 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T))) { 388 394 decoder.markInvalid(); 389 395 return false; … … 397 403 { 398 404 uint64_t decodedSize; 399 if (!decoder.decode(decodedSize)) 400 return WTF::nullopt; 401 402 auto size = safeCast<size_t>(decodedSize); 405 if (!decoder.decode(decodedSize)) { 406 decoder.markInvalid(); 407 return WTF::nullopt; 408 } 409 410 if (!WTF::isInBounds<size_t>(decodedSize)) { 411 decoder.markInvalid(); 412 return WTF::nullopt; 413 } 414 415 auto size = static_cast<size_t>(decodedSize); 403 416 404 417 // Since we know the total size of the elements, we can allocate the vector in … … 413 426 vector.grow(size); 414 427 415 Checked<size_t> checkedSize(size); 416 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(vector.data()), (checkedSize * sizeof(T)).unsafeGet(), alignof(T))) { 428 if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(vector.data()), size * sizeof(T), alignof(T))) { 417 429 decoder.markInvalid(); 418 430 return WTF::nullopt;
Note:
See TracChangeset
for help on using the changeset viewer.