mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser: Allow xattr globbing to match the NULL character
xattrs are a byte string that can contain all input characters including the null character. Allow * ** and ? glob patterns to match the null character while retaining their apparmor characteristics for '/'. That is * and ? won't traverse a '/' treating it as a path element. While ** will match anything. Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
2992e6973f
commit
6b47b8de25
1 changed files with 13 additions and 2 deletions
|
@ -227,7 +227,18 @@ pattern_t convert_aaregex_to_pcre(const char *aare, int anchor, int glob,
|
|||
} else {
|
||||
update_re_pos(sptr - aare);
|
||||
ptype = ePatternRegex;
|
||||
pcre.append("[^/\\x00]");
|
||||
switch (glob) {
|
||||
case glob_default:
|
||||
pcre.append("[^/\\x00]");
|
||||
break;
|
||||
case glob_null:
|
||||
pcre.append("[^/]");
|
||||
break;
|
||||
default:
|
||||
PERROR(_("%s: Invalid glob type %d\n"), progname, glob);
|
||||
error = e_parse_error;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -510,7 +521,7 @@ static int process_profile_name_xmatch(Profile *prof)
|
|||
int len;
|
||||
tbuf.clear();
|
||||
convert_aaregex_to_pcre(xattr_value, 0,
|
||||
glob_default, tbuf,
|
||||
glob_null, tbuf,
|
||||
&len);
|
||||
if (!rules->append_rule(tbuf.c_str(), true, dfaflags)) {
|
||||
delete rules;
|
||||
|
|
Loading…
Add table
Reference in a new issue