Skip to content

Commit

Permalink
src/bundle: fix leaking digest and salt in check_bundle_payload()
Browse files Browse the repository at this point in the history
The binary data returned by r_hex_decode() is not freed. Fix it.

Fixes coverity issue:
| CID 1445503 (#1 of 1): Resource leak (RESOURCE_LEAK)
| 23. leaked_storage: Variable root_digest going out of scope leaks the storage it points to.
  • Loading branch information
ejoerns committed Mar 2, 2022
1 parent 8e4bc16 commit a75494a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,8 +1720,8 @@ gboolean check_bundle_payload(RaucBundle *bundle, GError **error)
g_error("plain bundles must be verified during signature check");
} else if (bundle->manifest->bundle_format == R_MANIFEST_FORMAT_VERITY) {
int bundlefd = g_file_descriptor_based_get_fd(G_FILE_DESCRIPTOR_BASED(bundle->stream));
guint8 *root_digest = r_hex_decode(bundle->manifest->bundle_verity_hash, 32);
guint8 *salt = r_hex_decode(bundle->manifest->bundle_verity_salt, 32);
g_autofree guint8 *root_digest = r_hex_decode(bundle->manifest->bundle_verity_hash, 32);
g_autofree guint8 *salt = r_hex_decode(bundle->manifest->bundle_verity_salt, 32);
off_t combined_size = bundle->size;
off_t data_size = bundle->size - bundle->manifest->bundle_verity_size;
g_assert(root_digest);
Expand Down

0 comments on commit a75494a

Please sign in to comment.