Coverage Report

Created: 2026-12-01 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ntpsec/fuzz/FuzzServer.c
Line
Count
Source
1
/*
2
 * FuzzServer.c - OSS-Fuzz harness for NTS-KE server record processing
3
 * Copyright the NTPsec project contributors
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 *
6
 * Section references are to https://tools.ietf.org/html/rfc8915
7
 */
8
9
#include <stdio.h>
10
#include <stdlib.h>
11
#include <string.h>
12
#include "nts.h"
13
14
2.07k
#define kMinInputLength 20
15
1.00k
#define kMaxInputLength 1024
16
17
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
18
19
1.03k
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
20
1.03k
    if (Size < kMinInputLength || Size > kMaxInputLength) {
21
129
        return 0;
22
129
    }
23
24
    /* The parser walks the buffer with a mutable cursor, so give it a
25
     * writable copy instead of libFuzzer's read-only Data. */
26
909
    uint8_t *buff = malloc(Size);
27
909
    if (NULL == buff) {
28
0
        return 0;
29
0
    }
30
909
    memcpy(buff, Data, Size);
31
32
909
    NTS_Server_Info nsi;
33
909
    struct BufCtl_t buf;
34
35
909
    memset(&nsi, 0, sizeof(nsi));
36
909
    nsi.aead = NO_AEAD;    /* Dummy init value */
37
909
    buf.next = buff;
38
909
    buf.left = Size;
39
40
909
    (void)nts_ke_process_receive(&nsi, &buf);
41
42
909
    free(buff);
43
44
909
    return 0;
45
909
}