Green Sky
47ad96e2b6
da438763d5 chore: Release 0.2.19 f90417987c chore: Add cmake flag to disable unit tests. 7df3f99417 docs: Document that group topic lock is default on. 9e9ed77390 docs: Add missing param docs for callbacks. 0ec4978de5 refactor: Don't expose Tox_System in the public API a3d1b8595c docs: Public headers, Core/toxcore -> Tox/the Tox library f78d0f3f39 docs: Public headers, events_alloc -> internal 817518949e docs: Public headers, NULL-terminated -> NUL-terminated be085db191 docs: Public headers, spellcheck 4c902955f3 docs: Public headers, 80 column width comments be8a82a818 docs: Public headers, null -> NULL 419d783d95 docs: Public headers, tox -> Tox 5c8aa65e41 docs: Update user data API explanation ad4921dbaa cleanup: A more descriptive error for group invite accept function git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: da438763d5b8e071de6e061a1dcaddd2177dff7d
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#include <cassert>
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
#include "../../toxcore/tox.h"
|
|
#include "../../toxcore/tox_private.h"
|
|
#include "fuzz_support.hh"
|
|
|
|
namespace {
|
|
|
|
void TestSaveDataLoading(Fuzz_Data &input)
|
|
{
|
|
Tox_Err_Options_New error_options;
|
|
|
|
struct Tox_Options *tox_options = tox_options_new(&error_options);
|
|
|
|
assert(tox_options != nullptr);
|
|
assert(error_options == TOX_ERR_OPTIONS_NEW_OK);
|
|
|
|
const size_t savedata_size = input.size();
|
|
CONSUME_OR_RETURN(const uint8_t *savedata, input, savedata_size);
|
|
|
|
// pass test data to Tox
|
|
tox_options_set_savedata_data(tox_options, savedata, savedata_size);
|
|
tox_options_set_savedata_type(tox_options, TOX_SAVEDATA_TYPE_TOX_SAVE);
|
|
|
|
Tox_Options_Testing tox_options_testing;
|
|
Null_System sys;
|
|
tox_options_testing.operating_system = sys.sys.get();
|
|
|
|
Tox *tox = tox_new_testing(tox_options, nullptr, &tox_options_testing, nullptr);
|
|
tox_options_free(tox_options);
|
|
if (tox == nullptr) {
|
|
// Tox save was invalid, we're finished here
|
|
return;
|
|
}
|
|
|
|
// verify that the file can be saved again
|
|
std::vector<uint8_t> new_savedata(tox_get_savedata_size(tox));
|
|
tox_get_savedata(tox, new_savedata.data());
|
|
|
|
tox_kill(tox);
|
|
}
|
|
|
|
}
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
{
|
|
Fuzz_Data input{data, size};
|
|
TestSaveDataLoading(input);
|
|
return 0; // Non-zero return values are reserved for future use.
|
|
}
|