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

Commit 530a7536 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "MTP: Sanitize filename provided from MTP host" into qt-qpr1-dev am:...

Merge "MTP: Sanitize filename provided from MTP host" into qt-qpr1-dev am: 2d3c39c7 am: 7662f71b

Change-Id: If178b6eeaa50306458f8f191d626b51a0e4c1084
parents d6bd328e 7662f71b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include "android-base/strings.h"

namespace android {
static const int SN_EVENT_LOG_ID = 0x534e4554;

static const MtpOperationCode kSupportedOperationCodes[] = {
    MTP_OPERATION_GET_DEVICE_INFO,
@@ -967,6 +968,17 @@ MtpResponseCode MtpServer::doSendObjectInfo() {
    if (!parseDateTime(modified, modifiedTime))
        modifiedTime = 0;

    if ((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0) ||
        (strchr(name, '/') != NULL)) {
        char errMsg[80];

        snprintf(errMsg, sizeof(errMsg), "Invalid name: %s", (const char *) name);
        ALOGE("%s (b/130656917)", errMsg);
        android_errorWriteWithInfoLog(SN_EVENT_LOG_ID, "130656917", -1, errMsg,
                                      strlen(errMsg));

        return MTP_RESPONSE_INVALID_PARAMETER;
    }
    if (path[path.size() - 1] != '/')
        path.append("/");
    path.append(name);