All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Cashman <dcashman@android.com>
To: selinux@tycho.nsa.gov
Cc: sds@tycho.nsa.gov, jwcart2@tycho.nsa.gov, jeffv@google.com,
	dcashman <dcashman@android.com>
Subject: [PATCH 4/5] libsepol: cil: Fix CIL_OP data assignment.
Date: Thu,  8 Sep 2016 13:30:51 -0700	[thread overview]
Message-ID: <1473366652-23929-5-git-send-email-dcashman@android.com> (raw)
In-Reply-To: <1473366652-23929-4-git-send-email-dcashman@android.com>

From: dcashman <dcashman@android.com>

cil_flavor enums stored in cil_list_items are not pointers, but rather
the actual enum value.  Remove pointer dereferences on this value to
avoid segfaults.

Signed-off-by: Daniel Cashman <dcashman@android.com>
---
 libsepol/cil/src/cil_policy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libsepol/cil/src/cil_policy.c b/libsepol/cil/src/cil_policy.c
index 78b135e..32b6b41 100644
--- a/libsepol/cil/src/cil_policy.c
+++ b/libsepol/cil/src/cil_policy.c
@@ -470,7 +470,7 @@ void cil_perms_to_policy(FILE **file_arr, uint32_t file_index, struct cil_list *
 			fprintf(file_arr[file_index], " %s", ((struct cil_symtab_datum *)curr->data)->name);
 			break;
 		case CIL_OP: {
-			enum cil_flavor op_flavor = *((enum cil_flavor *)curr->data);
+			enum cil_flavor op_flavor = (enum cil_flavor)curr->data;
 			char *op_str = NULL;
 
 			switch (op_flavor) {
@@ -673,7 +673,7 @@ static int cil_expr_to_string(struct cil_list *expr, char **out)
 		case CIL_OP: {
 			int len;
 			char *expr_str;
-			enum cil_flavor op_flavor = *((enum cil_flavor *)curr->data);
+			enum cil_flavor op_flavor = (enum cil_flavor)curr->data;
 			char *op_str = NULL;
 
 			if (pos == 0) {
@@ -742,7 +742,7 @@ static int cil_expr_to_string(struct cil_list *expr, char **out)
 			break;
 		}
 		case CIL_CONS_OPERAND: {
-			enum cil_flavor operand_flavor = *((enum cil_flavor *)curr->data);
+			enum cil_flavor operand_flavor = (enum cil_flavor)curr->data;
 			char *operand_str = NULL;
 			switch (operand_flavor) {
 			case CIL_CONS_U1:
-- 
2.8.0.rc3.226.g39d4020

  reply	other threads:[~2016-09-08 20:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 20:30 [PATCH 0/5] Fix some cil_gen_policy() bugs Daniel Cashman
2016-09-08 20:30 ` [PATCH 1/5] libsepol: cil: Add userrole mapping to cil_gen_policy() Daniel Cashman
2016-09-08 20:30   ` [PATCH 2/5] libsepol: cil: Remove duplicate sid policy declaration Daniel Cashman
2016-09-08 20:30     ` [PATCH 3/5] libsepol: cil: Replace sensitivityorder statement Daniel Cashman
2016-09-08 20:30       ` Daniel Cashman [this message]
2016-09-08 20:30         ` [PATCH 5/5] libsepol: cil: Add cil_constraint_expr_to_policy() Daniel Cashman
2016-09-08 20:37 ` [PATCH 0/5] Fix some cil_gen_policy() bugs Daniel Cashman
2016-09-09 12:29   ` James Carter
2016-09-09 14:35     ` James Carter
2016-09-09 17:10       ` Daniel Cashman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473366652-23929-5-git-send-email-dcashman@android.com \
    --to=dcashman@android.com \
    --cc=jeffv@google.com \
    --cc=jwcart2@tycho.nsa.gov \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.