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

Commit 7681f87c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "media_player_service_fuzzer"

* changes:
  Fuzzing MediaPlayerService
  Instantiate MediaPlayerService for fuzzing
parents c1ea39b9 9f6358ac
Loading
Loading
Loading
Loading
+29 −15
Original line number Diff line number Diff line
@@ -17,7 +17,8 @@ license {
    ],
}

cc_library {
filegroup {
    name: "libmediaplayerservice_sources",

    srcs: [
        "ActivityManager.cpp",
@@ -30,6 +31,14 @@ cc_library {
        "StagefrightRecorder.cpp",
        "TestPlayerStub.cpp",
    ],
}

cc_defaults {
    name: "libmediaplayerservice_defaults",

    srcs: [
        ":libmediaplayerservice_sources",
    ],

    shared_libs: [
        "android.hardware.media.c2@1.0",
@@ -83,6 +92,24 @@ cc_library {
        "framework-permission-aidl-cpp",
    ],

    cflags: [
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wall",
    ],

    sanitize: {
        cfi: true,
    },
}

cc_library {
    name: "libmediaplayerservice",

    defaults: [
        "libmediaplayerservice_defaults",
    ],

    export_shared_lib_headers: [
        "libmedia",
        "framework-permission-aidl-cpp",
@@ -92,22 +119,9 @@ cc_library {
        "libmediautils_headers",
    ],

    local_include_dirs: ["include"],

    export_include_dirs: [
        ".",
    ],

    cflags: [
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wall",
    ],

    name: "libmediaplayerservice",

    sanitize: {
        cfi: true,
    },

    local_include_dirs: ["include"],
}
+7 −0
Original line number Diff line number Diff line
@@ -3038,4 +3038,11 @@ status_t MediaPlayerService::BatteryTracker::pullBatteryData(Parcel* reply) {
    }
    return NO_ERROR;
}

#ifdef FUZZ_MODE_MEDIA_PLAYER_SERVICE
sp<MediaPlayerService> MediaPlayerService::createForFuzzTesting() {
    return sp<MediaPlayerService>::make();
}
#endif // FUZZ_MODE_MEDIA_PLAYER_SERVICE

} // namespace android
+6 −0
Original line number Diff line number Diff line
@@ -505,6 +505,12 @@ private:
                SortedVector< wp<Client> >  mClients;
                SortedVector< wp<MediaRecorderClient> > mMediaRecorderClients;
                int32_t                     mNextConnId;

#ifdef FUZZ_MODE_MEDIA_PLAYER_SERVICE
public:
    friend class sp<MediaPlayerService>;
    static sp<MediaPlayerService> createForFuzzTesting();
#endif // FUZZ_MODE_MEDIA_PLAYER_SERVICE
};

// ----------------------------------------------------------------------------
+23 −0
Original line number Diff line number Diff line
@@ -139,3 +139,26 @@ cc_fuzz {
        "libstagefright_httplive",
    ],
}

cc_fuzz {
    name: "media_player_service_fuzzer",
    defaults: [
        "service_fuzzer_defaults",
        "libmediaplayerservice_defaults",
        "fuzzer_disable_leaks",
    ],
    srcs: [
        "media_player_service_fuzzer.cpp",
    ],
    fuzz_config: {
        cc: [
            "kyslov@google.com",
            "ibaker@google.com",
        ],
        triage_assignee: "waghpawan@google.com",
    },
    cflags: [
        "-DFUZZ_MODE_MEDIA_PLAYER_SERVICE",
    ],
    include_dirs: ["frameworks/av/media/libmediaplayerservice/"],
}
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <fuzzbinder/libbinder_driver.h>
#include <fuzzer/FuzzedDataProvider.h>

#include <MediaPlayerService.h>

using android::fuzzService;
using android::MediaPlayerService;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
    auto service = MediaPlayerService::createForFuzzTesting();
    fuzzService(service, FuzzedDataProvider(data, size));
    return 0;
}