Coverage Report

Created: 2023-09-25 07:10

/src/libssh/tests/fuzz/ssh_client_config_fuzzer.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2021 Stanislav Zidek <szidek@redhat.com>
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
#include <assert.h>
18
#include <stdio.h>
19
#include <stdlib.h>
20
#include <string.h>
21
22
#define LIBSSH_STATIC 1
23
#include "libssh/libssh.h"
24
#include "libssh/options.h"
25
26
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
27
377
{
28
377
    ssh_session session = NULL;
29
377
    char *input = NULL;
30
31
377
    input = (char *)malloc(size+1);
32
377
    if (!input) {
33
0
        return 1;
34
0
    }
35
377
    strncpy(input, (const char *)data, size);
36
377
    input[size] = '\0';
37
38
377
    ssh_init();
39
40
377
    session = ssh_new();
41
377
    assert(session != NULL);
42
43
    /* Make sure we have default options set */
44
377
    ssh_options_set(session, SSH_OPTIONS_SSH_DIR, NULL);
45
377
    ssh_options_set(session, SSH_OPTIONS_HOST, "example.com");
46
47
377
    ssh_config_parse_string(session, input);
48
49
377
    ssh_free(session);
50
377
    ssh_finalize();
51
52
377
    free(input);
53
54
377
    return 0;
55
377
}