|
|
83845a |
From 1711757378d1ff1e7437fd7d5ddf263272284641 Mon Sep 17 00:00:00 2001
|
|
|
83845a |
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
|
|
|
83845a |
Date: Tue, 6 Jul 2021 19:54:33 +0200
|
|
|
83845a |
Subject: [PATCH] checkpolicy: mark read-only parameters in policy define const
|
|
|
83845a |
MIME-Version: 1.0
|
|
|
83845a |
Content-Type: text/plain; charset=UTF-8
|
|
|
83845a |
Content-Transfer-Encoding: 8bit
|
|
|
83845a |
|
|
|
83845a |
Make it more obvious which parameters are read-only and not being
|
|
|
83845a |
modified and allow callers to pass const pointers.
|
|
|
83845a |
|
|
|
83845a |
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
|
|
|
83845a |
---
|
|
|
83845a |
checkpolicy/policy_define.c | 15 ++++++++-------
|
|
|
83845a |
1 file changed, 8 insertions(+), 7 deletions(-)
|
|
|
83845a |
|
|
|
83845a |
diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
|
|
|
83845a |
index efe3a1a26315..75a67d5c8a7c 100644
|
|
|
83845a |
--- a/checkpolicy/policy_define.c
|
|
|
83845a |
+++ b/checkpolicy/policy_define.c
|
|
|
83845a |
@@ -77,7 +77,7 @@ extern int yyerror(const char *msg);
|
|
|
83845a |
#define ERRORMSG_LEN 255
|
|
|
83845a |
static char errormsg[ERRORMSG_LEN + 1] = {0};
|
|
|
83845a |
|
|
|
83845a |
-static int id_has_dot(char *id);
|
|
|
83845a |
+static int id_has_dot(const char *id);
|
|
|
83845a |
static int parse_security_context(context_struct_t *c);
|
|
|
83845a |
|
|
|
83845a |
/* initialize all of the state variables for the scanner/parser */
|
|
|
83845a |
@@ -141,7 +141,7 @@ int insert_id(const char *id, int push)
|
|
|
83845a |
|
|
|
83845a |
/* If the identifier has a dot within it and that its first character
|
|
|
83845a |
is not a dot then return 1, else return 0. */
|
|
|
83845a |
-static int id_has_dot(char *id)
|
|
|
83845a |
+static int id_has_dot(const char *id)
|
|
|
83845a |
{
|
|
|
83845a |
if (strchr(id, '.') >= id + 1) {
|
|
|
83845a |
return 1;
|
|
|
83845a |
@@ -2172,7 +2172,7 @@ void avrule_xperm_setrangebits(uint16_t low, uint16_t high,
|
|
|
83845a |
}
|
|
|
83845a |
}
|
|
|
83845a |
|
|
|
83845a |
-int avrule_xperms_used(av_extended_perms_t *xperms)
|
|
|
83845a |
+int avrule_xperms_used(const av_extended_perms_t *xperms)
|
|
|
83845a |
{
|
|
|
83845a |
unsigned int i;
|
|
|
83845a |
|
|
|
83845a |
@@ -2347,7 +2347,7 @@ unsigned int xperms_for_each_bit(unsigned int *bit, av_extended_perms_t *xperms)
|
|
|
83845a |
return 0;
|
|
|
83845a |
}
|
|
|
83845a |
|
|
|
83845a |
-int avrule_cpy(avrule_t *dest, avrule_t *src)
|
|
|
83845a |
+int avrule_cpy(avrule_t *dest, const avrule_t *src)
|
|
|
83845a |
{
|
|
|
83845a |
class_perm_node_t *src_perms;
|
|
|
83845a |
class_perm_node_t *dest_perms, *dest_tail;
|
|
|
83845a |
@@ -2395,7 +2395,7 @@ int avrule_cpy(avrule_t *dest, avrule_t *src)
|
|
|
83845a |
return 0;
|
|
|
83845a |
}
|
|
|
83845a |
|
|
|
83845a |
-int define_te_avtab_ioctl(avrule_t *avrule_template)
|
|
|
83845a |
+int define_te_avtab_ioctl(const avrule_t *avrule_template)
|
|
|
83845a |
{
|
|
|
83845a |
avrule_t *avrule;
|
|
|
83845a |
struct av_ioctl_range_list *rangelist;
|
|
|
83845a |
@@ -3444,9 +3444,10 @@ bad:
|
|
|
83845a |
return -1;
|
|
|
83845a |
}
|
|
|
83845a |
|
|
|
83845a |
-static constraint_expr_t *constraint_expr_clone(constraint_expr_t * expr)
|
|
|
83845a |
+static constraint_expr_t *constraint_expr_clone(const constraint_expr_t * expr)
|
|
|
83845a |
{
|
|
|
83845a |
- constraint_expr_t *h = NULL, *l = NULL, *e, *newe;
|
|
|
83845a |
+ constraint_expr_t *h = NULL, *l = NULL, *newe;
|
|
|
83845a |
+ const constraint_expr_t *e;
|
|
|
83845a |
for (e = expr; e; e = e->next) {
|
|
|
83845a |
newe = malloc(sizeof(*newe));
|
|
|
83845a |
if (!newe)
|
|
|
83845a |
--
|
|
|
83845a |
2.32.0
|
|
|
83845a |
|