Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7d23869 authored by Devin Moore's avatar Devin Moore Committed by Automerger Merge Worker
Browse files

Check mDataPos to see if the Parcel needs to grow am: f0b1c904

parents be7ea301 f0b1c904
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -455,7 +455,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
    }
    int numObjects = lastIndex - firstIndex + 1;

    if ((mDataSize+len) > mDataCapacity) {
    if ((mDataPos + len) > mDataCapacity) {
        // grow data
        err = growData(len);
        if (err != NO_ERROR) {
+11 −0
Original line number Diff line number Diff line
@@ -112,6 +112,17 @@ TEST(Parcel, DebugReadAllFds) {
    EXPECT_EQ(ret[1], STDIN_FILENO);
}

TEST(Parcel, AppendWithBadDataPos) {
    Parcel p1;
    p1.writeInt32(1);
    p1.writeInt32(1);
    Parcel p2;
    p2.setDataCapacity(8);
    p2.setDataPosition(10000);

    EXPECT_EQ(android::BAD_VALUE, p2.appendFrom(&p1, 0, 8));
}

// Tests a second operation results in a parcel at the same location as it
// started.
void parcelOpSameLength(const std::function<void(Parcel*)>& a, const std::function<void(Parcel*)>& b) {