summaryrefslogtreecommitdiff
path: root/oss-fuzz/fuzz-credential-from-url-gently.c
blob: c872f9ad2d123ead221ba855538c6cc3f36a6bd5 (plain)
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
#include "git-compat-util.h"
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "credential.h"

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
	struct credential c;
	char *buf;

	buf = malloc(size + 1);
	if (!buf)
		return 0;

	memcpy(buf, data, size);
	buf[size] = 0;

	// start fuzzing
	credential_init(&c);
	credential_from_url_gently(&c, buf, 1);

	// cleanup
	credential_clear(&c);
	free(buf);

	return 0;
}