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 <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Christian Göttsche 2022-06-10 17:06:23 +02:00 committed by James Carter
parent 956bda08f6
commit f505a73b06

View file

@ -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;
}
/*