libsepol: avoid potential NULL dereference on optional parameter
PATCH 1/1 libsepol: avoid potential NULL dereference on optional parameter
The parameter reason of context_struct_compute_av() is optional and can be passed in as NULL, like from type_attribute_bounds_av().
Signed-off-by Christian Göttsche <[email protected]>
--- libsepol/src/services.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libsepol/src/services.c +2 -1
@@ -894,7 +894,8 @@ static void type_attribute_bounds_av(context_struct_t *scontext,/* mask violated permissions */ avd->allowed &= ~masked; - *reason |=SEPOL_COMPUTEAV_BOUNDS ; +if (reason) + *reason |=SEPOL_COMPUTEAV_BOUNDS ; }/*
Signature · 1 line
2.36.1
Quoted 5 lines · Christian Göttsche
The parameter
reasonofcontext_struct_compute_av()is optional and can be passed in as NULL, like fromtype_attribute_bounds_av().Signed-off-by Christian Göttsche <[email protected]>
Acked-by James Carter <[email protected]>
Quoted 21 lines
--- libsepol/src/services.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)libsepol/src/services.c +2
-2@@ -894,7 +894,8 @@ static void type_attribute_bounds_av(context_struct_t *scontext,/* mask violated permissions */ avd->allowed &= ~masked; - *reason |=SEPOL_COMPUTEAV_BOUNDS ; +if (reason) + *reason |=SEPOL_COMPUTEAV_BOUNDS ; }/* -- 2.36.1
Quoted 11 lines · James Carter
Quoted 5 lines · Christian Göttsche
The parameter
reasonofcontext_struct_compute_av()is optional and can be passed in as NULL, like fromtype_attribute_bounds_av().Signed-off-by Christian Göttsche <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 21 lines
Quoted 21 lines
--- libsepol/src/services.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)libsepol/src/services.c +2
-2@@ -894,7 +894,8 @@ static void type_attribute_bounds_av(context_struct_t *scontext,/* mask violated permissions */ avd->allowed &= ~masked; - *reason |=SEPOL_COMPUTEAV_BOUNDS ; +if (reason) + *reason |=SEPOL_COMPUTEAV_BOUNDS ; }/* -- 2.36.1