Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
external_libselinux
Commits
3fbac6e7
Commit
3fbac6e7
authored
10 years ago
by
Nick Kralevich
Committed by
Gerrit Code Review
10 years ago
Browse files
Options
Download
Plain Diff
Merge "libselinux: mapping fix for invalid class/perms after selinux_set_mapping call"
parents
46e21256
574290e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
13 deletions
+28
-13
src/mapping.c
src/mapping.c
+28
-13
No files found.
src/mapping.c
View file @
3fbac6e7
...
...
@@ -6,7 +6,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include <selinux/selinux.h>
#include <selinux/avc.h>
#include "mapping.h"
...
...
@@ -103,8 +102,13 @@ unmap_class(security_class_t tclass)
if
(
tclass
<
current_mapping_size
)
return
current_mapping
[
tclass
].
value
;
assert
(
current_mapping_size
==
0
);
return
tclass
;
/* If here no mapping set or the class requested is not valid. */
if
(
current_mapping_size
!=
0
)
{
errno
=
EINVAL
;
return
0
;
}
else
return
tclass
;
}
access_vector_t
...
...
@@ -116,16 +120,19 @@ unmap_perm(security_class_t tclass, access_vector_t tperm)
for
(
i
=
0
;
i
<
current_mapping
[
tclass
].
num_perms
;
i
++
)
if
(
tperm
&
(
1
<<
i
))
{
assert
(
current_mapping
[
tclass
].
perms
[
i
]);
kperm
|=
current_mapping
[
tclass
].
perms
[
i
];
tperm
&=
~
(
1
<<
i
);
}
assert
(
tperm
==
0
);
return
kperm
;
}
assert
(
current_mapping_size
==
0
);
return
tperm
;
/* If here no mapping set or the perm requested is not valid. */
if
(
current_mapping_size
!=
0
)
{
errno
=
EINVAL
;
return
0
;
}
else
return
tperm
;
}
/*
...
...
@@ -141,8 +148,13 @@ map_class(security_class_t kclass)
if
(
current_mapping
[
i
].
value
==
kclass
)
return
i
;
assert
(
current_mapping_size
==
0
);
return
kclass
;
/* If here no mapping set or the class requested is not valid. */
if
(
current_mapping_size
!=
0
)
{
errno
=
EINVAL
;
return
0
;
}
else
return
kclass
;
}
access_vector_t
...
...
@@ -157,11 +169,14 @@ map_perm(security_class_t tclass, access_vector_t kperm)
tperm
|=
1
<<
i
;
kperm
&=
~
current_mapping
[
tclass
].
perms
[
i
];
}
assert
(
kperm
==
0
);
return
tperm
;
}
assert
(
current_mapping_size
==
0
);
if
(
tperm
==
0
)
{
errno
=
EINVAL
;
return
0
;
}
else
return
tperm
;
}
return
kperm
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment