summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpStorageInfo.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@google.com>2014-11-13 16:49:14 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-13 16:49:14 +0000
commite1e814c7c640a51511b149985d57f8bfd4a8bf78 (patch)
treee80535c005c41fc25e24648fa0fa5f50b2d53137 /media/mtp/MtpStorageInfo.cpp
parentdd1b265eb3041532ad76d41bb73dbe9722decf7f (diff)
parente418cfae0970d1abe60b8cc681aa8c8a828b3769 (diff)
downloadframeworks_av-e1e814c7c640a51511b149985d57f8bfd4a8bf78.zip
frameworks_av-e1e814c7c640a51511b149985d57f8bfd4a8bf78.tar.gz
frameworks_av-e1e814c7c640a51511b149985d57f8bfd4a8bf78.tar.bz2
am e418cfae: am 869e0798: Merge "MTP: add strict bounds checking for all incoming packets" into lmp-mr1-dev
* commit 'e418cfae0970d1abe60b8cc681aa8c8a828b3769': MTP: add strict bounds checking for all incoming packets
Diffstat (limited to 'media/mtp/MtpStorageInfo.cpp')
-rw-r--r--media/mtp/MtpStorageInfo.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/media/mtp/MtpStorageInfo.cpp b/media/mtp/MtpStorageInfo.cpp
index 2b1a9ae..5d4ebbf 100644
--- a/media/mtp/MtpStorageInfo.cpp
+++ b/media/mtp/MtpStorageInfo.cpp
@@ -45,21 +45,23 @@ MtpStorageInfo::~MtpStorageInfo() {
free(mVolumeIdentifier);
}
-void MtpStorageInfo::read(MtpDataPacket& packet) {
+bool MtpStorageInfo::read(MtpDataPacket& packet) {
MtpStringBuffer string;
// read the device info
- mStorageType = packet.getUInt16();
- mFileSystemType = packet.getUInt16();
- mAccessCapability = packet.getUInt16();
- mMaxCapacity = packet.getUInt64();
- mFreeSpaceBytes = packet.getUInt64();
- mFreeSpaceObjects = packet.getUInt32();
+ if (!packet.getUInt16(mStorageType)) return false;
+ if (!packet.getUInt16(mFileSystemType)) return false;
+ if (!packet.getUInt16(mAccessCapability)) return false;
+ if (!packet.getUInt64(mMaxCapacity)) return false;
+ if (!packet.getUInt64(mFreeSpaceBytes)) return false;
+ if (!packet.getUInt32(mFreeSpaceObjects)) return false;
- packet.getString(string);
+ if (!packet.getString(string)) return false;
mStorageDescription = strdup((const char *)string);
- packet.getString(string);
+ if (!packet.getString(string)) return false;
mVolumeIdentifier = strdup((const char *)string);
+
+ return true;
}
void MtpStorageInfo::print() {