diff options
| author | 2016-09-30 00:26:15 +0000 | |
|---|---|---|
| committer | 2016-09-30 00:26:15 +0000 | |
| commit | bc09f98c4e8c05dfc77c09ee523086d5ce148441 (patch) | |
| tree | b98f51b3beacfaf5c20100ef28820e3f180b08d1 | |
| parent | 983c69303b267d67cfde714531cb41fec6347240 (diff) | |
| parent | 87109469b04e950d41af10386a8f009c0b6b0ee1 (diff) | |
Merge "Fix implicit sign casts in Parcel.h" am: 9984fa0ed0 am: 4901e7c070 am: 7600934e17
am: 87109469b0
Change-Id: I4de63e308760a6c079bb07763cd05b3ba9608f5c
| -rw-r--r-- | include/binder/Parcel.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index bba3f363ba..feba5bab15 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -542,7 +542,10 @@ template<typename T> status_t Parcel::write(const LightFlattenable<T>& val) { size_t size(val.getFlattenedSize()); if (!val.isFixedSize()) { - status_t err = writeInt32(size); + if (size > INT32_MAX) { + return BAD_VALUE; + } + status_t err = writeInt32(static_cast<int32_t>(size)); if (err != NO_ERROR) { return err; } @@ -573,7 +576,7 @@ status_t Parcel::read(LightFlattenable<T>& val) const { if (err != NO_ERROR) { return err; } - size = s; + size = static_cast<size_t>(s); } if (size) { void const* buffer = readInplace(size); @@ -588,7 +591,7 @@ status_t Parcel::writeVectorSize(const std::vector<T>& val) { if (val.size() > INT32_MAX) { return BAD_VALUE; } - return writeInt32(val.size()); + return writeInt32(static_cast<int32_t>(val.size())); } template<typename T> @@ -678,7 +681,7 @@ status_t Parcel::unsafeReadTypedVector( return UNEXPECTED_NULL; } - val->resize(size); + val->resize(static_cast<size_t>(size)); for (auto& v: *val) { status = (this->*read_func)(&v); @@ -700,7 +703,7 @@ status_t Parcel::readTypedVector(std::vector<T>* val, template<typename T> status_t Parcel::readNullableTypedVector(std::unique_ptr<std::vector<T>>* val, status_t(Parcel::*read_func)(T*) const) const { - const int32_t start = dataPosition(); + const size_t start = dataPosition(); int32_t size; status_t status = readInt32(&size); val->reset(); @@ -728,7 +731,7 @@ status_t Parcel::unsafeWriteTypedVector(const std::vector<T>& val, return BAD_VALUE; } - status_t status = this->writeInt32(val.size()); + status_t status = this->writeInt32(static_cast<int32_t>(val.size())); if (status != OK) { return status; @@ -784,7 +787,7 @@ status_t Parcel::readParcelableVector(std::vector<T>* val) const { template<typename T> status_t Parcel::readParcelableVector(std::unique_ptr<std::vector<std::unique_ptr<T>>>* val) const { - const int32_t start = dataPosition(); + const size_t start = dataPosition(); int32_t size; status_t status = readInt32(&size); val->reset(); @@ -807,7 +810,7 @@ status_t Parcel::readParcelableVector(std::unique_ptr<std::vector<std::unique_pt template<typename T> status_t Parcel::readParcelable(std::unique_ptr<T>* parcelable) const { - const int32_t start = dataPosition(); + const size_t start = dataPosition(); int32_t present; status_t status = readInt32(&present); parcelable->reset(); |