Coverage Report

Created: 2023-09-25 07:10

/src/libssh/tests/fuzz/ssh_bind_config_fuzzer.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2021 Jakub Jelen <jjelen@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/server.h"
25
#include "libssh/bind_config.h"
26
27
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
28
377
{
29
377
    ssh_bind bind = NULL;
30
377
    char *input = NULL;
31
32
377
    input = (char *)malloc(size + 1);
33
377
    if (!input) {
34
0
        return 1;
35
0
    }
36
377
    strncpy(input, (const char *)data, size);
37
377
    input[size] = '\0';
38
39
377
    ssh_init();
40
41
377
    bind = ssh_bind_new();
42
377
    assert(bind != NULL);
43
44
377
    ssh_bind_config_parse_string(bind, input);
45
46
377
    ssh_bind_free(bind);
47
377
    ssh_finalize();
48
49
377
    free(input);
50
51
377
    return 0;
52
377
}