Coverage Report

Created: 2026-09-01 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/plugins/variables/ext-variables-settings.c
Line
Count
Source
1
/* Copyright (c) Pigeonhole authors, see top-level COPYING file */
2
3
#include "lib.h"
4
#include "array.h"
5
#include "settings.h"
6
#include "settings-parser.h"
7
8
#include "ext-variables-limits.h"
9
#include "ext-variables-settings.h"
10
11
static bool
12
ext_variables_settings_check(void *_set, pool_t pool ATTR_UNUSED,
13
           const char **error_r);
14
15
#undef DEF
16
#define DEF(type, name) \
17
  SETTING_DEFINE_STRUCT_##type("sieve_variables_"#name, name, \
18
             struct ext_variables_settings)
19
20
static const struct setting_define ext_variables_setting_defines[] = {
21
  DEF(UINT, max_scope_count),
22
  DEF(SIZE, max_value_size),
23
24
  SETTING_DEFINE_LIST_END,
25
};
26
27
static const struct ext_variables_settings ext_variables_default_settings = {
28
  .max_scope_count = 255,
29
  .max_value_size = (4 * 1024),
30
};
31
32
const struct setting_parser_info ext_variables_setting_parser_info = {
33
  .name = "sieve_variables",
34
35
  .defines = ext_variables_setting_defines,
36
  .defaults = &ext_variables_default_settings,
37
38
  .struct_size = sizeof(struct ext_variables_settings),
39
40
  .check_func = ext_variables_settings_check,
41
42
  .pool_offset1 = 1 + offsetof(struct ext_variables_settings, pool),
43
};
44
45
/* <settings checks> */
46
static bool
47
ext_variables_settings_check(void *_set, pool_t pool ATTR_UNUSED,
48
           const char **error_r)
49
0
{
50
0
  struct ext_variables_settings *set = _set;
51
52
0
  if (set->max_scope_count < EXT_VARIABLES_REQUIRED_MAX_SCOPE_COUNT) {
53
0
    *error_r = t_strdup_printf(
54
0
        "Setting sieve_variables_max_scope_count "
55
0
        "is lower than required by standards "
56
0
        "(>= %u items)",
57
0
        EXT_VARIABLES_REQUIRED_MAX_SCOPE_COUNT);
58
0
    return FALSE;
59
0
  }
60
0
  if (set->max_value_size < EXT_VARIABLES_REQUIRED_MAX_VALUE_SIZE) {
61
0
    *error_r = t_strdup_printf(
62
0
        "Setting sieve_variables_max_variable_size "
63
0
        "is lower than required by standards "
64
0
        "(>= %zu bytes)",
65
0
        (size_t)EXT_VARIABLES_REQUIRED_MAX_VALUE_SIZE);
66
0
    return FALSE;
67
0
  }
68
69
0
  return TRUE;
70
0
}
71
/* </settings checks> */
72