Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sepolicy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test
platform
system
sepolicy
Commits
9b5b32c0
Commit
9b5b32c0
authored
8 years ago
by
TreeHugger Robot
Committed by
Android (Google) Code Review
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Port from pcre to pcre2 (Fix wrong merge decision)" into stage-aosp-master
parents
28a896bf
750d797b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/Android.mk
+1
-2
1 addition, 2 deletions
tools/Android.mk
tools/check_seapp.c
+32
-19
32 additions, 19 deletions
tools/check_seapp.c
with
33 additions
and
21 deletions
tools/Android.mk
+
1
−
2
View file @
9b5b32c0
...
@@ -5,12 +5,11 @@ include $(CLEAR_VARS)
...
@@ -5,12 +5,11 @@ include $(CLEAR_VARS)
LOCAL_MODULE
:=
checkseapp
LOCAL_MODULE
:=
checkseapp
LOCAL_MODULE_TAGS
:=
optional
LOCAL_MODULE_TAGS
:=
optional
LOCAL_C_INCLUDES
:=
\
LOCAL_C_INCLUDES
:=
\
external/pcre
\
external/selinux/libsepol/include
external/selinux/libsepol/include
LOCAL_CFLAGS
:=
-DLINK_SEPOL_STATIC
-Wall
-Werror
LOCAL_CFLAGS
:=
-DLINK_SEPOL_STATIC
-Wall
-Werror
LOCAL_SRC_FILES
:=
check_seapp.c
LOCAL_SRC_FILES
:=
check_seapp.c
LOCAL_STATIC_LIBRARIES
:=
libsepol
LOCAL_STATIC_LIBRARIES
:=
libsepol
LOCAL_WHOLE_STATIC_LIBRARIES
:=
libpcre
LOCAL_WHOLE_STATIC_LIBRARIES
:=
libpcre
2
LOCAL_CXX_STL
:=
none
LOCAL_CXX_STL
:=
none
include
$(BUILD_HOST_EXECUTABLE)
include
$(BUILD_HOST_EXECUTABLE)
...
...
This diff is collapsed.
Click to expand it.
tools/check_seapp.c
+
32
−
19
View file @
9b5b32c0
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#include
<stdbool.h>
#include
<stdbool.h>
#include
<sepol/sepol.h>
#include
<sepol/sepol.h>
#include
<sepol/policydb/policydb.h>
#include
<sepol/policydb/policydb.h>
#include
<pcre.h>
#include
<pcre
2
.h>
#define TABLE_SIZE 1024
#define TABLE_SIZE 1024
#define KVP_NUM_OF_RULES (sizeof(rules) / sizeof(key_map))
#define KVP_NUM_OF_RULES (sizeof(rules) / sizeof(key_map))
...
@@ -91,8 +91,8 @@ struct list {
...
@@ -91,8 +91,8 @@ struct list {
};
};
struct
key_map_regex
{
struct
key_map_regex
{
pcre
*
compiled
;
pcre
2_code
*
compiled
;
pcre
_extra
*
extr
a
;
pcre
2_match_data
*
match_dat
a
;
};
};
/**
/**
...
@@ -320,14 +320,15 @@ static bool match_regex(key_map *assert, const key_map *check) {
...
@@ -320,14 +320,15 @@ static bool match_regex(key_map *assert, const key_map *check) {
char
*
tomatch
=
check
->
data
;
char
*
tomatch
=
check
->
data
;
int
ret
=
pcre_exec
(
assert
->
regex
.
compiled
,
assert
->
regex
.
extra
,
tomatch
,
int
ret
=
pcre2_match
(
assert
->
regex
.
compiled
,
(
PCRE2_SPTR
)
tomatch
,
strlen
(
tomatch
),
0
,
0
,
NULL
,
0
);
PCRE2_ZERO_TERMINATED
,
0
,
0
,
assert
->
regex
.
match_data
,
NULL
);
/* 0 from pcre
_exec
means matched */
/*
ret >
0 from pcre
2_match
means matched */
return
!
ret
;
return
ret
>
0
;
}
}
static
bool
compile_regex
(
key_map
*
km
,
const
char
**
errbuf
,
int
*
erroff
)
{
static
bool
compile_regex
(
key_map
*
km
,
int
*
errcode
,
PCRE2_SIZE
*
erroff
)
{
size_t
size
;
size_t
size
;
char
*
anchored
;
char
*
anchored
;
...
@@ -341,13 +342,21 @@ static bool compile_regex(key_map *km, const char **errbuf, int *erroff) {
...
@@ -341,13 +342,21 @@ static bool compile_regex(key_map *km, const char **errbuf, int *erroff) {
anchored
=
alloca
(
size
);
anchored
=
alloca
(
size
);
sprintf
(
anchored
,
"^%s$"
,
km
->
data
);
sprintf
(
anchored
,
"^%s$"
,
km
->
data
);
km
->
regex
.
compiled
=
pcre_compile
(
anchored
,
PCRE_DOTALL
,
errbuf
,
erroff
,
km
->
regex
.
compiled
=
pcre2_compile
((
PCRE2_SPTR
)
anchored
,
NULL
);
PCRE2_ZERO_TERMINATED
,
PCRE2_DOTALL
,
errcode
,
erroff
,
NULL
);
if
(
!
km
->
regex
.
compiled
)
{
if
(
!
km
->
regex
.
compiled
)
{
return
false
;
return
false
;
}
}
km
->
regex
.
extra
=
pcre_study
(
km
->
regex
.
compiled
,
0
,
errbuf
);
km
->
regex
.
match_data
=
pcre2_match_data_create_from_pattern
(
km
->
regex
.
compiled
,
NULL
);
if
(
!
km
->
regex
.
match_data
)
{
pcre2_code_free
(
km
->
regex
.
compiled
);
return
false
;
}
return
true
;
return
true
;
}
}
...
@@ -423,12 +432,13 @@ static bool validate_selinux_level(char *value, char **errmsg) {
...
@@ -423,12 +432,13 @@ static bool validate_selinux_level(char *value, char **errmsg) {
static
bool
key_map_validate
(
key_map
*
m
,
const
char
*
filename
,
int
lineno
,
static
bool
key_map_validate
(
key_map
*
m
,
const
char
*
filename
,
int
lineno
,
bool
is_neverallow
)
{
bool
is_neverallow
)
{
int
erroff
;
PCRE2_SIZE
erroff
;
const
char
*
errbuf
;
int
errcode
;
bool
rc
=
true
;
bool
rc
=
true
;
char
*
key
=
m
->
name
;
char
*
key
=
m
->
name
;
char
*
value
=
m
->
data
;
char
*
value
=
m
->
data
;
char
*
errmsg
=
NULL
;
char
*
errmsg
=
NULL
;
char
errstr
[
256
];
log_info
(
"Validating %s=%s
\n
"
,
key
,
value
);
log_info
(
"Validating %s=%s
\n
"
,
key
,
value
);
...
@@ -438,10 +448,13 @@ static bool key_map_validate(key_map *m, const char *filename, int lineno,
...
@@ -438,10 +448,13 @@ static bool key_map_validate(key_map *m, const char *filename, int lineno,
*/
*/
if
(
is_neverallow
)
{
if
(
is_neverallow
)
{
if
(
!
m
->
regex
.
compiled
)
{
if
(
!
m
->
regex
.
compiled
)
{
rc
=
compile_regex
(
m
,
&
err
buf
,
&
erroff
);
rc
=
compile_regex
(
m
,
&
err
code
,
&
erroff
);
if
(
!
rc
)
{
if
(
!
rc
)
{
log_error
(
"Invalid regex on line %d : %s PCRE error: %s at offset %d"
,
pcre2_get_error_message
(
errcode
,
lineno
,
value
,
errbuf
,
erroff
);
(
PCRE2_UCHAR
*
)
errstr
,
sizeof
(
errstr
));
log_error
(
"Invalid regex on line %d : %s PCRE error: %s at offset %lu"
,
lineno
,
value
,
errstr
,
erroff
);
}
}
}
}
goto
out
;
goto
out
;
...
@@ -572,11 +585,11 @@ static void rule_map_free(rule_map *rm, bool is_in_htable) {
...
@@ -572,11 +585,11 @@ static void rule_map_free(rule_map *rm, bool is_in_htable) {
free
(
m
->
data
);
free
(
m
->
data
);
if
(
m
->
regex
.
compiled
)
{
if
(
m
->
regex
.
compiled
)
{
pcre_free
(
m
->
regex
.
compiled
);
pcre
2_code
_free
(
m
->
regex
.
compiled
);
}
}
if
(
m
->
regex
.
extr
a
)
{
if
(
m
->
regex
.
match_dat
a
)
{
pcre
_free_study
(
m
->
regex
.
extr
a
);
pcre
2_match_data_free
(
m
->
regex
.
match_dat
a
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment