aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiƩbaud Weksteen <tweek@google.com>2022-01-27 11:36:16 +1100
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-14 23:12:28 +0000
commitb6f173c5582a4d8f55b00b17d3cdb91fff809e30 (patch)
tree2ef35f99409eb08bc6cc14acd2ab436a02eb80ec
parent2a2a8b42a693be7a7a3f4dc5552406baa598b46a (diff)
Skip closef for property backend
In 50400d3 the selabel_open function was updated to call selabel_close should the initialization of a backend fails. selabel_close includes a call to the backend-specific close function: closef. This same function is previously call, in case of an error, within the init function. The file backend was adapted by introducing a safe guard to prevent a double free. Update the property backend in a similar fashion. Bug: 215387420 Test: build & boot Change-Id: Id6b7c4d10538ccbec43b2af1de462da077f10c44 (cherry picked from commit 98fa1b865d52d97c06b754d1c2cfb69315997b65) Merged-In:Id6b7c4d10538ccbec43b2af1de462da077f10c44
-rw-r--r--libselinux/src/label_backends_android.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libselinux/src/label_backends_android.c b/libselinux/src/label_backends_android.c
index d81faabe..121b52f5 100644
--- a/libselinux/src/label_backends_android.c
+++ b/libselinux/src/label_backends_android.c
@@ -278,6 +278,12 @@ static void closef(struct selabel_handle *rec)
struct spec *spec;
unsigned int i;
+ if (!data)
+ return;
+
+ /* make sure successive ->func_close() calls are harmless */
+ rec->data = NULL;
+
if (data->spec_arr) {
for (i = 0; i < data->nspec; i++) {
spec = &data->spec_arr[i];