• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

proftpd / proftpd / 26127302613

19 May 2026 09:51PM UTC coverage: 93.024% (+0.4%) from 92.635%
26127302613

push

github

51329 of 55178 relevant lines covered (93.02%)

215.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.77
/src/filter.c
1
/*
2
 * ProFTPD - FTP server daemon
3
 * Copyright (c) 2009-2026 The ProFTPD Project team
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, see <https://www.gnu.org/licenses/>.
17
 *
18
 * As a special exemption, The ProFTPD Project team and other respective
19
 * copyright holders give permission to link this program with OpenSSL, and
20
 * distribute the resulting executable, without including the source code for
21
 * OpenSSL in the source distribution.
22
 */
23

24
#include "conf.h"
25

26
static const char *trace_channel = "filter";
27

28
int pr_filter_allow_path(xaset_t *set, const char *path) {
29
#ifdef PR_USE_REGEX
5✔
30
  pr_regex_t *pre;
31
  int res;
5✔
32

5✔
33
  if (set == NULL ||
34
      path == NULL) {
5✔
35
    errno = EINVAL;
5✔
36
    return -1;
1✔
37
  }
1✔
38

39
  /* Check any relevant PathAllowFilter first. */
40

41
  pre = get_param_ptr(set, "PathAllowFilter", FALSE);
42
  if (pre != NULL) {
4✔
43
    res = pr_regexp_exec(pre, path, 0, NULL, 0, 0, 0);
4✔
44
    if (res != 0) {
1✔
45
      return PR_FILTER_ERR_FAILS_ALLOW_FILTER;
1✔
46
    }
47

48
    pr_trace_msg(trace_channel, 8, "'%s' allowed by PathAllowFilter '%s'", path,
49
      pr_regexp_get_pattern(pre));
×
50
  }
51

52
  /* Next check any applicable PathDenyFilter. */
53

54
  pre = get_param_ptr(set, "PathDenyFilter", FALSE);
55
  if (pre != NULL) {
3✔
56
    res = pr_regexp_exec(pre, path, 0, NULL, 0, 0, 0);
3✔
57
    if (res == 0) {
2✔
58
      return PR_FILTER_ERR_FAILS_DENY_FILTER;
2✔
59
    }
60

61
    pr_trace_msg(trace_channel, 8, "'%s' allowed by PathDenyFilter '%s'", path,
62
      pr_regexp_get_pattern(pre));
1✔
63
  }
64

65
  return 0;
66
#else
67
  return 0;
68
#endif
69
}
70

71
int pr_filter_parse_flags(pool *p, const char *flags_str) {
72
  size_t flags_len;
7✔
73

7✔
74
  if (p == NULL ||
75
      flags_str == NULL) {
7✔
76
    errno = EINVAL;
7✔
77
    return -1;
3✔
78
  }
3✔
79

80
  flags_len = strlen(flags_str);
81

4✔
82
  if (flags_str[0] != '[' ||
83
      flags_str[flags_len-1] != ']') {
4✔
84
    errno = EINVAL;
3✔
85
    return -1;
1✔
86
  }
1✔
87

88
  /* Right now, we only support "[NC]", for "no case", i.e. REG_ICASE. */
89
  if (strcmp(flags_str, "[NC]") == 0 ||
90
      strcmp(flags_str, "[nocase]") == 0) {
3✔
91
    return REG_ICASE;
2✔
92
  }
2✔
93

94
  return 0;
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc