blob: 364186abe27dac2a35de402c320262411236ff24 (
plain) (
blame)
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
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST
extern inline size_t librecrypt_chain_length(const char *hash);
#else
# ifndef FUZZ
int
main(void)
{
SET_UP_ALARM();
INIT_RESOURCE_TEST();
/* Check returns number of '>' plus 1 */
EXPECT(librecrypt_chain_length("") == 1u);
EXPECT(librecrypt_chain_length("a$b") == 1u);
EXPECT(librecrypt_chain_length(">") == 2u);
EXPECT(librecrypt_chain_length(">>") == 3u);
EXPECT(librecrypt_chain_length("a$b>c$d>e$f") == 3u);
EXPECT(librecrypt_chain_length("a$b>c$d>e$f>") == 4u);
EXPECT(librecrypt_chain_length(">a$b>c$d>e$f>") == 5u);
STOP_RESOURCE_TEST();
return 0;
}
# else
extern volatile size_t discarded_return_value;
volatile size_t discarded_return_value;
int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
(void) size;
discarded_return_value = librecrypt_chain_length((const void *)data);
return 0;
}
# endif
#endif
|