Skip to content

Commit

Permalink
try to save the fuzzed save file again
Browse files Browse the repository at this point in the history
This should test some additional code paths.
  • Loading branch information
sudden6 committed Mar 24, 2022
1 parent 7dde71c commit fc5a664
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion testing/fuzzing/toxsave_harness.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <cassert>
#include <cstdint>
#include <vector>

#include "../../toxcore/tox.h"

Expand All @@ -16,8 +18,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
tox_options_set_savedata_type(tox_options, TOX_SAVEDATA_TYPE_TOX_SAVE);

Tox *tox = tox_new(tox_options, nullptr);

tox_options_free(tox_options);
if (tox == nullptr) {
// Tox save was invalid, we're finished here
return 0;
}

// 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);
return 0; // Non-zero return values are reserved for future use.
Expand Down

0 comments on commit fc5a664

Please sign in to comment.