Coverage Report

Created: 2026-02-14 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open62541/tests/fuzz/fuzz_pubsub_json.cc
Line
Count
Source
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
 *
5
 *    Copyright 2026 (c) Ze Sheng 
6
 */
7
8
#include <open62541/types.h>
9
#include <open62541/pubsub.h>
10
#include "custom_memory_manager.h"
11
12
extern "C" int
13
9.05k
LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
14
9.05k
    if(size < 4)
15
4
        return 0;
16
17
    /* Set memory limit from last 4 bytes to test OOM handling */
18
9.05k
    if(!UA_memoryManager_setLimitFromLast4Bytes(data, size))
19
0
        return 0;
20
9.05k
    size -= 4;
21
22
    /* Create ByteString from fuzz input */
23
9.05k
    UA_ByteString buf;
24
9.05k
    buf.data = (UA_Byte*)(void*)data;
25
9.05k
    buf.length = size;
26
27
    /* Decode the NetworkMessage from JSON */
28
9.05k
    UA_NetworkMessage nm;
29
9.05k
    memset(&nm, 0, sizeof(UA_NetworkMessage));
30
31
9.05k
    UA_StatusCode rv = UA_NetworkMessage_decodeJson(&buf, &nm, NULL, NULL);
32
9.05k
    if(rv == UA_STATUSCODE_GOOD) {
33
37
        UA_NetworkMessage_clear(&nm);
34
37
    }
35
36
9.05k
    return 0;
37
9.05k
}