1 /* Copyright (c) 2016-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #define CONSDIFF_PRIVATE
7 #include "core/or/or.h"
8 #include "feature/dircommon/consdiff.h"
10 #include "test/fuzz/fuzzing.h"
13 mock_consensus_compute_digest_(const char *c
, size_t len
,
14 consensus_digest_t
*d
)
18 memset(d
->sha3_256
, 3, sizeof(d
->sha3_256
));
23 mock_consensus_digest_eq_(const uint8_t *a
, const uint8_t *b
)
33 MOCK(consensus_compute_digest
, mock_consensus_compute_digest_
);
34 MOCK(consensus_digest_eq
, mock_consensus_digest_eq_
);
41 UNMOCK(consensus_compute_digest
);
42 UNMOCK(consensus_digest_eq
);
47 fuzz_main(const uint8_t *stdin_buf
, size_t data_size
)
50 #define SEPLEN strlen(SEP)
51 const uint8_t *separator
= tor_memmem(stdin_buf
, data_size
, SEP
, SEPLEN
);
54 size_t c1_len
= separator
- stdin_buf
;
55 const char *c1
= (const char *)stdin_buf
;
56 size_t c2_len
= data_size
- c1_len
- SEPLEN
;
57 const char *c2
= (const char *)separator
+ SEPLEN
;
59 char *c3
= consensus_diff_apply(c1
, c1_len
, c2
, c2_len
);