Coverage Report

Created: 2026-07-16 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/librabbitmq/fuzz/fuzz_properties_decode.c
Line
Count
Source
1
// Copyright 2007 - 2026, Arthur Chan and the rabbitmq-c contributors.
2
// SPDX-License-Identifier: mit
3
4
#include <errno.h>
5
#include <inttypes.h>
6
#include <math.h>
7
#include <stdarg.h>
8
#include <stdio.h>
9
#include <stdlib.h>
10
#include <string.h>
11
12
#include <rabbitmq-c/amqp.h>
13
#include <rabbitmq-c/framing.h>
14
15
// Drives amqp_decode_properties(), the generated decoder for every AMQP
16
// content-header (properties) frame. The first 2 bytes are the class id
17
// (big-endian), the rest the body.
18
5.98k
extern int LLVMFuzzerTestOneInput(const char *data, size_t size) {
19
20
5.98k
  int unused_result;
21
5.98k
  amqp_pool_t pool;
22
5.98k
  uint16_t class_id;
23
24
5.98k
  if (size < 2) {
25
3
    return 0;
26
3
  }
27
28
5.98k
  class_id = ((uint16_t)(uint8_t)data[0] << 8) |
29
5.98k
             ((uint16_t)(uint8_t)data[1]);
30
31
5.98k
  init_amqp_pool(&pool, 4096);
32
5.98k
  {
33
5.98k
    void *decoded = NULL;
34
5.98k
    amqp_bytes_t encoded;
35
5.98k
    encoded.len = size - 2;
36
5.98k
    encoded.bytes = (void *)(data + 2);
37
38
5.98k
    unused_result = amqp_decode_properties(class_id, &pool, encoded, &decoded);
39
5.98k
  }
40
5.98k
  empty_amqp_pool(&pool);
41
5.98k
  return 0;
42
5.98k
}