Skip to content

Commit 7a1ad63

Browse files
author
Mike Lockwood
committed
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: Mike Lockwood <lockwood@google.com>
1 parent 55347e6 commit 7a1ad63

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

media/mtp/MtpDataPacket.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
#include "MtpDataPacket.h"
2626
#include "MtpStringBuffer.h"
2727

28+
#define MTP_BUFFER_SIZE 16384
29+
2830
namespace android {
2931

3032
MtpDataPacket::MtpDataPacket()
31-
: MtpPacket(16384), // MAX_USBFS_BUFFER_SIZE
33+
: MtpPacket(MTP_BUFFER_SIZE), // MAX_USBFS_BUFFER_SIZE
3234
mOffset(MTP_CONTAINER_HEADER_SIZE)
3335
{
3436
}
@@ -345,7 +347,7 @@ void MtpDataPacket::putString(const uint16_t* string) {
345347

346348
#ifdef MTP_DEVICE
347349
int MtpDataPacket::read(int fd) {
348-
int ret = ::read(fd, mBuffer, mBufferSize);
350+
int ret = ::read(fd, mBuffer, MTP_BUFFER_SIZE);
349351
if (ret < MTP_CONTAINER_HEADER_SIZE)
350352
return -1;
351353
mPacketSize = ret;

0 commit comments

Comments
 (0)