Skip to content

Commit b61a070

Browse files
committed
libbinder Parcel: Fix ubsan error in readData
Use don't cast the result of readInplace before calling memcpy to align the data. With clang-r522817 passing an unaligned pointer to memcpy also triggers a ubsan error. Bug: 354981705 Change-Id: Ibd104bcfac519211857f1e9e93a1ec35e7bcd773
1 parent 9333e35 commit b61a070

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

libs/binder/include/binder/Parcel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ class Parcel {
12401240
if (__builtin_mul_overflow(size, sizeof(T), &dataLen)) {
12411241
return -EOVERFLOW;
12421242
}
1243-
auto data = reinterpret_cast<const T*>(readInplace(dataLen));
1243+
auto data = readInplace(dataLen);
12441244
if (data == nullptr) return BAD_VALUE;
12451245
// std::vector::insert and similar methods will require type-dependent
12461246
// byte alignment when inserting from a const iterator such as `data`,

0 commit comments

Comments
 (0)