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

Commit 8af4c7d0 authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MTP: Don't attempt to read more than 16K at a time from the MTP driver DO NOT MERGE



This could happen sometimes if other operations increased the size of the
data packet buffer to > 16K

Change-Id: I10f85f0ce32df39f46b0a984361958c0a13f6800
Signed-off-by: default avatarMike Lockwood <lockwood@google.com>
parent 4fe1c6c3
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -25,10 +25,12 @@
#include "MtpDataPacket.h"
#include "MtpDataPacket.h"
#include "MtpStringBuffer.h"
#include "MtpStringBuffer.h"


#define MTP_BUFFER_SIZE 16384

namespace android {
namespace android {


MtpDataPacket::MtpDataPacket()
MtpDataPacket::MtpDataPacket()
    :   MtpPacket(16384),   // MAX_USBFS_BUFFER_SIZE
    :   MtpPacket(MTP_BUFFER_SIZE),   // MAX_USBFS_BUFFER_SIZE
        mOffset(MTP_CONTAINER_HEADER_SIZE)
        mOffset(MTP_CONTAINER_HEADER_SIZE)
{
{
}
}
@@ -345,7 +347,7 @@ void MtpDataPacket::putString(const uint16_t* string) {


#ifdef MTP_DEVICE 
#ifdef MTP_DEVICE 
int MtpDataPacket::read(int fd) {
int MtpDataPacket::read(int fd) {
    int ret = ::read(fd, mBuffer, mBufferSize);
    int ret = ::read(fd, mBuffer, MTP_BUFFER_SIZE);
    if (ret < MTP_CONTAINER_HEADER_SIZE)
    if (ret < MTP_CONTAINER_HEADER_SIZE)
        return -1;
        return -1;
    mPacketSize = ret;
    mPacketSize = ret;