diff options
author | Mike Lockwood <lockwood@google.com> | 2014-11-13 16:49:14 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-11-13 16:49:14 +0000 |
commit | e1e814c7c640a51511b149985d57f8bfd4a8bf78 (patch) | |
tree | e80535c005c41fc25e24648fa0fa5f50b2d53137 /media/mtp/MtpDataPacket.h | |
parent | dd1b265eb3041532ad76d41bb73dbe9722decf7f (diff) | |
parent | e418cfae0970d1abe60b8cc681aa8c8a828b3769 (diff) | |
download | frameworks_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/MtpDataPacket.h')
-rw-r--r-- | media/mtp/MtpDataPacket.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/media/mtp/MtpDataPacket.h b/media/mtp/MtpDataPacket.h index 2b81063..13d3bd9 100644 --- a/media/mtp/MtpDataPacket.h +++ b/media/mtp/MtpDataPacket.h @@ -30,7 +30,7 @@ class MtpStringBuffer; class MtpDataPacket : public MtpPacket { private: // current offset for get/put methods - int mOffset; + size_t mOffset; public: MtpDataPacket(); @@ -42,17 +42,18 @@ public: void setTransactionID(MtpTransactionID id); inline const uint8_t* getData() const { return mBuffer + MTP_CONTAINER_HEADER_SIZE; } - inline uint8_t getUInt8() { return (uint8_t)mBuffer[mOffset++]; } - inline int8_t getInt8() { return (int8_t)mBuffer[mOffset++]; } - uint16_t getUInt16(); - inline int16_t getInt16() { return (int16_t)getUInt16(); } - uint32_t getUInt32(); - inline int32_t getInt32() { return (int32_t)getUInt32(); } - uint64_t getUInt64(); - inline int64_t getInt64() { return (int64_t)getUInt64(); } - void getUInt128(uint128_t& value); - inline void getInt128(int128_t& value) { getUInt128((uint128_t&)value); } - void getString(MtpStringBuffer& string); + + bool getUInt8(uint8_t& value); + inline bool getInt8(int8_t& value) { return getUInt8((uint8_t&)value); } + bool getUInt16(uint16_t& value); + inline bool getInt16(int16_t& value) { return getUInt16((uint16_t&)value); } + bool getUInt32(uint32_t& value); + inline bool getInt32(int32_t& value) { return getUInt32((uint32_t&)value); } + bool getUInt64(uint64_t& value); + inline bool getInt64(int64_t& value) { return getUInt64((uint64_t&)value); } + bool getUInt128(uint128_t& value); + inline bool getInt128(int128_t& value) { return getUInt128((uint128_t&)value); } + bool getString(MtpStringBuffer& string); Int8List* getAInt8(); UInt8List* getAUInt8(); |