Merge "Set sehandle in voldFuzzer"

This commit is contained in:
Pawan Wagh 2023-03-16 07:28:40 +00:00 committed by Gerrit Code Review
commit c1572fe8cf

View file

@ -14,15 +14,27 @@
* limitations under the License. * limitations under the License.
*/ */
#include <android-base/logging.h>
#include <fuzzbinder/libbinder_driver.h> #include <fuzzbinder/libbinder_driver.h>
#include "VoldNativeService.h" #include "VoldNativeService.h"
#include "sehandle.h"
using ::android::fuzzService; using ::android::fuzzService;
using ::android::sp; using ::android::sp;
struct selabel_handle* sehandle; struct selabel_handle* sehandle;
extern "C" int LLVMFuzzerInitialize(int argc, char argv) {
sehandle = selinux_android_file_context_handle();
if (!sehandle) {
LOG(ERROR) << "Failed to get SELinux file contexts handle in voldFuzzer!";
exit(1);
}
selinux_android_set_sehandle(sehandle);
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
auto voldService = sp<android::vold::VoldNativeService>::make(); auto voldService = sp<android::vold::VoldNativeService>::make();
fuzzService(voldService, FuzzedDataProvider(data, size)); fuzzService(voldService, FuzzedDataProvider(data, size));