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

proftpd / proftpd / 28259826111

26 Jun 2026 07:20PM UTC coverage: 93.032% (+0.6%) from 92.469%
28259826111

push

github

51363 of 55210 relevant lines covered (93.03%)

200.05 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
#if defined(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
  pre = get_param_ptr(set, "PathAllowFilter", FALSE);
41
  if (pre != NULL) {
42
    res = pr_regexp_exec(pre, path, 0, NULL, 0, 0, 0);
4✔
43
    if (res != 0) {
4✔
44
      return PR_FILTER_ERR_FAILS_ALLOW_FILTER;
1✔
45
    }
1✔
46

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

51
  /* Next check any applicable PathDenyFilter. */
52
  pre = get_param_ptr(set, "PathDenyFilter", FALSE);
53
  if (pre != NULL) {
54
    res = pr_regexp_exec(pre, path, 0, NULL, 0, 0, 0);
55
    if (res == 0) {
3✔
56
      return PR_FILTER_ERR_FAILS_DENY_FILTER;
3✔
57
    }
2✔
58

2✔
59
    pr_trace_msg(trace_channel, 8, "'%s' allowed by PathDenyFilter '%s'", path,
60
      pr_regexp_get_pattern(pre));
61
  }
62
#endif /* PR_USE_REGEX */
1✔
63

64
  return 0;
65
}
66

67
int pr_filter_parse_flags(pool *p, const char *flags_str) {
68
  size_t flags_len;
69

70
  if (p == NULL ||
71
      flags_str == NULL) {
72
    errno = EINVAL;
7✔
73
    return -1;
7✔
74
  }
75

7✔
76
  flags_len = strlen(flags_str);
7✔
77

3✔
78
  if (flags_str[0] != '[' ||
3✔
79
      flags_str[flags_len-1] != ']') {
80
    errno = EINVAL;
81
    return -1;
4✔
82
  }
83

4✔
84
  /* Right now, we only support "[NC]", for "no case", i.e. REG_ICASE. */
3✔
85
  if (strcmp(flags_str, "[NC]") == 0 ||
1✔
86
      strcmp(flags_str, "[nocase]") == 0) {
1✔
87
    return REG_ICASE;
88
  }
89

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

© 2026 Coveralls, Inc