You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
4 months ago
|
/*
|
||
|
* Copyright (C) 2020 The Android Open Source Project
|
||
|
*
|
||
|
* This software is licensed under the terms of the GNU General Public
|
||
|
* License version 2, as published by the Free Software Foundation, and
|
||
|
* may be copied, distributed, and modified under those terms.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*/
|
||
|
|
||
|
#include <fstream>
|
||
|
#include <iostream>
|
||
|
|
||
|
#include "diskio.h"
|
||
|
#include "mbr.h"
|
||
|
#include "gpt.h"
|
||
|
|
||
|
#include <fuzzer/FuzzedDataProvider.h>
|
||
|
|
||
|
std::ofstream silence("/dev/null");
|
||
|
|
||
|
extern "C" int LLVMFuzzerInitialize(int *, char ***) {
|
||
|
std::cout.rdbuf(silence.rdbuf());
|
||
|
std::cerr.rdbuf(silence.rdbuf());
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||
|
DiskIO disk;
|
||
|
disk.OpenForRead(static_cast<const unsigned char*>(data), size);
|
||
|
|
||
|
BasicMBRData mbrData;
|
||
|
mbrData.ReadMBRData(&disk);
|
||
|
|
||
|
GPTData gptData;
|
||
|
gptData.SetDisk(disk);
|
||
|
gptData.LoadPartitions("/dev/does_not_exist");
|
||
|
|
||
|
return 0;
|
||
|
}
|