diff mbox series

[3/5] libsepol/cil: Check for empty list when marking neverallow attributes

Message ID 20210614150546.512001-4-jwcart2@gmail.com (mailing list archive)
State Superseded
Headers show
Series Another round of secilc-fuzzer problems fixed | expand

Commit Message

James Carter June 14, 2021, 3:05 p.m. UTC
When marking a type attribute as used in a neverallow (to help determine
whether or not it should be expanded), check if the attribute's expression
list is empty (no attributes are associated with it) before iterating
over the list.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/cil/src/cil_post.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Nicolas Iooss June 19, 2021, 2:21 p.m. UTC | #1
On Mon, Jun 14, 2021 at 5:05 PM James Carter <jwcart2@gmail.com> wrote:
>
> When marking a type attribute as used in a neverallow (to help determine
> whether or not it should be expanded), check if the attribute's expression
> list is empty (no attributes are associated with it) before iterating
> over the list.
>
> Signed-off-by: James Carter <jwcart2@gmail.com>

For this patch:

Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Thanks!

> ---
>  libsepol/cil/src/cil_post.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
> index 05842b64..38544aef 100644
> --- a/libsepol/cil/src/cil_post.c
> +++ b/libsepol/cil/src/cil_post.c
> @@ -1494,6 +1494,10 @@ static void __mark_neverallow_attrs(struct cil_list *expr_list)
>  {
>         struct cil_list_item *curr;
>
> +       if (!expr_list) {
> +               return;
> +       }
> +
>         cil_list_for_each(curr, expr_list) {
>                 if (curr->flavor == CIL_DATUM) {
>                         if (FLAVOR(curr->data) == CIL_TYPEATTRIBUTE) {
> --
> 2.26.3
>
diff mbox series

Patch

diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
index 05842b64..38544aef 100644
--- a/libsepol/cil/src/cil_post.c
+++ b/libsepol/cil/src/cil_post.c
@@ -1494,6 +1494,10 @@  static void __mark_neverallow_attrs(struct cil_list *expr_list)
 {
 	struct cil_list_item *curr;
 
+	if (!expr_list) {
+		return;
+	}
+
 	cil_list_for_each(curr, expr_list) {
 		if (curr->flavor == CIL_DATUM) {
 			if (FLAVOR(curr->data) == CIL_TYPEATTRIBUTE) {