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

Commit 9b88b72e authored by Mike Lockwood's avatar Mike Lockwood
Browse files

MTP: Return error if user tries to copy a file >= 4GB to a FAT32 file system



Bug: 4561836

Change-Id: I2bffb93b032038f6c220c24c752ccd7ca66c23a0
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent bca946c7
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -871,6 +871,14 @@ MtpResponseCode MtpServer::doSendObjectInfo() {
    // check space first
    if (mSendObjectFileSize > storage->getFreeSpace())
        return MTP_RESPONSE_STORAGE_FULL;
    uint64_t maxFileSize = storage->getMaxFileSize();
    // check storage max file size
    if (maxFileSize != 0) {
        // if mSendObjectFileSize is 0xFFFFFFFF, then all we know is the file size
        // is >= 0xFFFFFFFF
        if (mSendObjectFileSize > maxFileSize || mSendObjectFileSize == 0xFFFFFFFF)
            return MTP_RESPONSE_OBJECT_TOO_LARGE;
    }

LOGD("path: %s parent: %d storageID: %08X", (const char*)path, parent, storageID);
    MtpObjectHandle handle = mDatabase->beginSendObject((const char*)path,
+3 −1
Original line number Diff line number Diff line
@@ -33,11 +33,13 @@
namespace android {

MtpStorage::MtpStorage(MtpStorageID id, const char* filePath,
        const char* description, uint64_t reserveSpace, bool removable)
        const char* description, uint64_t reserveSpace,
        bool removable, uint64_t maxFileSize)
    :   mStorageID(id),
        mFilePath(filePath),
        mDescription(description),
        mMaxCapacity(0),
        mMaxFileSize(maxFileSize),
        mReserveSpace(reserveSpace),
        mRemovable(removable)
{
+3 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ private:
    MtpString               mFilePath;
    MtpString               mDescription;
    uint64_t                mMaxCapacity;
    uint64_t                mMaxFileSize;
    // amount of free space to leave unallocated
    uint64_t                mReserveSpace;
    bool                    mRemovable;
@@ -38,7 +39,7 @@ private:
public:
                            MtpStorage(MtpStorageID id, const char* filePath,
                                    const char* description, uint64_t reserveSpace,
                                    bool removable);
                                    bool removable, uint64_t maxFileSize);
    virtual                 ~MtpStorage();

    inline MtpStorageID     getStorageID() const { return mStorageID; }
@@ -50,6 +51,7 @@ public:
    const char*             getDescription() const;
    inline const char*      getPath() const { return (const char *)mFilePath; }
    inline bool             isRemovable() const { return mRemovable; }
    inline uint64_t         getMaxFileSize() const { return mMaxFileSize; }
};

}; // namespace android