Coverage Report

Created: 2026-08-31 07:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mod_auth_openidc/test/fuzz/fuzz_base64.c
Line
Count
Source
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  Licensed under the Apache License,
4
 * Version 2.0 (the "License"); you may not use this file except in
5
 * compliance with the License.  You may obtain a copy of the License at
6
 *
7
 *   http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Copyright (C) 2017-2026 ZmartZone Holding BV - hans.zandbelt@openidc.com
10
 *
11
 * Fuzz target for oidc_util_base64url_decode(): base64url decoding of
12
 * attacker-controlled strings (cookies, state, JWT segments all flow through
13
 * here).
14
 */
15
16
#include "fuzz.h"
17
#include "util.h"      /* test fixture: oidc_test_setup / oidc_test_pool_get */
18
#include "util/util.h" /* oidc_util_base64url_decode */
19
20
#include <apr_pools.h>
21
#include <apr_strings.h>
22
23
static int g_ready = 0;
24
25
/* engine-called one-time init, pre-forkserver on AFL++: see fuzz.h */
26
34
int LLVMFuzzerInitialize(int *argc, char ***argv) {
27
34
  (void)argc;
28
34
  (void)argv;
29
34
  if (!g_ready) {
30
34
    oidc_test_setup();
31
34
    g_ready = 1;
32
34
  }
33
34
  return 0;
34
34
}
35
36
6.63k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
37
6.63k
  if (!g_ready)
38
0
    LLVMFuzzerInitialize(NULL, NULL);
39
40
6.63k
  apr_pool_t *pool = NULL;
41
6.63k
  apr_pool_create(&pool, oidc_test_pool_get());
42
43
  /* the decoder takes a NUL-terminated C string */
44
6.63k
  char *src = apr_pstrmemdup(pool, (const char *)data, size);
45
6.63k
  char *dst = NULL;
46
6.63k
  oidc_util_base64url_decode(pool, &dst, src);
47
48
6.63k
  apr_pool_destroy(pool);
49
6.63k
  return 0;
50
6.63k
}