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

Commit 3747d8ec authored by Daichi Hirono's avatar Daichi Hirono Committed by Android (Google) Code Review
Browse files

Merge "Fix MtpDevice to read 0-byte object correctly."

parents 0d236f50 a04e6fa6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -659,6 +659,13 @@ bool MtpDevice::readObjectInternal(MtpObjectHandle handle,
        return false;
    }

    // If object size 0 byte, the remote device can reply response packet
    // without sending any data packets.
    if (mData.getContainerType() == MTP_CONTAINER_TYPE_RESPONSE) {
        mResponse.copyFrom(mData);
        return mResponse.getResponseCode() == MTP_RESPONSE_OK;
    }

    const uint32_t fullLength = mData.getContainerLength();
    if ((!expectedLength && fullLength < MTP_CONTAINER_HEADER_SIZE) ||
        (expectedLength && *expectedLength + MTP_CONTAINER_HEADER_SIZE != fullLength)) {