xref: /freebsd/crypto/openssh/regress/misc/fuzz-harness/authopt_fuzz.cc (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1 #include <stddef.h>
2 #include <stdio.h>
3 #include <stdint.h>
4 #include <string.h>
5 #include <stdlib.h>
6 
7 extern "C" {
8 
9 #include "auth-options.h"
10 
11 int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
12 {
13 	char *cp = (char *)malloc(size + 1);
14 	struct sshauthopt *opts = NULL, *merge = NULL, *add = sshauthopt_new();
15 
16 	if (cp == NULL || add == NULL)
17 		goto out;
18 	memcpy(cp, data, size);
19 	cp[size] = '\0';
20 	if ((opts = sshauthopt_parse(cp, NULL)) == NULL)
21 		goto out;
22 	if ((merge = sshauthopt_merge(opts, add, NULL)) == NULL)
23 		goto out;
24 
25  out:
26 	free(cp);
27 	sshauthopt_free(add);
28 	sshauthopt_free(opts);
29 	sshauthopt_free(merge);
30 	return 0;
31 }
32 
33 } // extern "C"
34