Skip to content

Commit

Permalink
libselinux: free memory on selabel_open(3) failure
Browse files Browse the repository at this point in the history
If selabel_open(3) fails, e.g. when a specfile has the wrong file
permissions, free the memory allocated for digests.

Fixes: e40bbea ("libselinux: Add selabel_digest function")
Acked-by: James Carter <[email protected]>
Signed-off-by: Christian Göttsche <[email protected]>
  • Loading branch information
cgzones authored and jwcart2 committed Apr 20, 2022
1 parent 63df12f commit b9a4d13
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libselinux/src/label.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ struct selabel_handle *selabel_open(unsigned int backend,
rec->digest = selabel_is_digest_set(opts, nopts, rec->digest);

if ((*initfuncs[backend])(rec, opts, nopts)) {
if (rec->digest)
selabel_digest_fini(rec->digest);
free(rec->spec_file);
free(rec);
rec = NULL;
Expand Down

0 comments on commit b9a4d13

Please sign in to comment.