-
Notifications
You must be signed in to change notification settings - Fork 30
/
fuzz_url.cc
56 lines (50 loc) · 1.76 KB
/
fuzz_url.cc
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
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2017 - 2022, Max Dymond, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include "curl_fuzzer.h"
/**
* Fuzzing entry point. This function is passed a buffer containing a test
* case. This test case should drive the CURL URL API.
*/
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
CURLU *uh;
char *newp;
uh = curl_url();
/* it works on a null-terminated string */
if(size) {
newp = (char *)malloc(size + 1);
if(newp) {
memcpy(newp, data, size);
/* make sure it is zero terminated */
newp[size] = 0;
curl_url_set(uh, CURLUPART_URL, newp, CURLU_GUESS_SCHEME);
free(newp);
}
}
curl_url_cleanup(uh);
/* This function must always return 0. Non-zero codes are reserved. */
return 0;
}