forked from stateafl/stateafl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aflnet-to-plain.c
64 lines (37 loc) · 1022 Bytes
/
aflnet-to-plain.c
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
if(argc < 2) {
printf("Usage: %s <input file>\n", argv[0]);
exit(1);
}
char * infile = argv[1];
char outfile[FILENAME_MAX + 6];
snprintf(outfile, strlen(infile) + 6 + 1, "%s.plain", infile);
printf("Input file: %s\n", infile);
printf("Output file: %s\n", outfile);
FILE * input_fd = fopen(infile, "rb");
if(!input_fd) {
perror("Unable to open input file");
exit(1);
}
FILE * output_fd = fopen(outfile, "wb");
if(!output_fd) {
perror("Unable to open output file");
exit(1);
}
int len;
int ret;
ret = fread(&len, sizeof(int), 1, input_fd);
while(ret > 0) {
printf("Len: %d\n", len);
char * buffer = malloc(len);;
ret = fread(buffer, sizeof(char), len, input_fd);
ret = fwrite(buffer, sizeof(char), len, output_fd);
free(buffer);
ret = fread(&len, sizeof(int), 1, input_fd);
}
fclose(input_fd);
fclose(output_fd);
}