From 44c190826d72589f5c9e13d69e32673bd8bd7c64 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Thu, 1 Dec 2011 18:36:06 -0500 Subject: MTP: Don't attempt to read more than 16K at a time from the MTP driver This could happen sometimes if other operations increased the size of the data packet buffer to > 16K Change-Id: I4d316c7e2e558d3dd861d39accae6514fd9a62f5 Signed-off-by: Mike Lockwood --- media/mtp/MtpDataPacket.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'media/mtp') diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp index 20225ba..cfea7e8 100644 --- a/media/mtp/MtpDataPacket.cpp +++ b/media/mtp/MtpDataPacket.cpp @@ -25,10 +25,12 @@ #include "MtpDataPacket.h" #include "MtpStringBuffer.h" +#define MTP_BUFFER_SIZE 16384 + namespace android { MtpDataPacket::MtpDataPacket() - : MtpPacket(16384), // MAX_USBFS_BUFFER_SIZE + : MtpPacket(MTP_BUFFER_SIZE), // MAX_USBFS_BUFFER_SIZE mOffset(MTP_CONTAINER_HEADER_SIZE) { } @@ -345,7 +347,7 @@ void MtpDataPacket::putString(const uint16_t* string) { #ifdef MTP_DEVICE 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) return -1; mPacketSize = ret; -- cgit v1.1