diff options
author | 2024-10-08 20:03:56 -0700 | |
---|---|---|
committer | 2024-10-08 20:11:20 -0700 | |
commit | b61a07068ae78e55ddb1ac0d8b100ce522927a3d (patch) | |
tree | 4874fa8919bd834ded1af9af3be4c859930cde89 | |
parent | 9333e35abee0b81d533cd9853fa57bdf3fe5c503 (diff) |
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
-rw-r--r-- | libs/binder/include/binder/Parcel.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h index c394ac70c8..15a0da765e 100644 --- a/libs/binder/include/binder/Parcel.h +++ b/libs/binder/include/binder/Parcel.h @@ -1240,7 +1240,7 @@ private: if (__builtin_mul_overflow(size, sizeof(T), &dataLen)) { return -EOVERFLOW; } - auto data = reinterpret_cast<const T*>(readInplace(dataLen)); + auto data = readInplace(dataLen); if (data == nullptr) return BAD_VALUE; // std::vector::insert and similar methods will require type-dependent // byte alignment when inserting from a const iterator such as `data`, |