-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathharness-1.cpp
37 lines (26 loc) · 956 Bytes
/
harness-1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <cstring>
#include <stdbool.h>
#include <iostream>
#include <fstream>
#include <string>
#include <assert.h>
#include "snappy.h"
int main(int argc, char *argv[])
{
/* Read input file to fuzzing data. */
std::ifstream fuzz_file((char*) argv[1]);
std::string str_cur, str_fin;
while (getline (fuzz_file, str_cur)) {
str_fin.append(str_cur);
}
const char* fuzz_data = str_fin.data();
/* Process fuzzing data to RawUncompress. */
std::string str_Compress;
std::string str_Uncompress;
size_t sizet_Compress = snappy::Compress(fuzz_data, strlen(fuzz_data), &str_Compress);
bool bool_Uncompress = snappy::Uncompress(str_Compress.data(), strlen(str_Compress.data()), &str_Uncompress);
assert(bool_Uncompress == true);
bool bool_RawUncompress = snappy::RawUncompress((const char*) str_Uncompress.data(), (size_t) sizet_Compress, (char*) str_Compress.data());
return 0;
}