repo: Validate checksums have correct length
ostree_checksum_bytes_peek() can return NULL if the checksum has an incorrect length (most likely from disk corruption) but most callers are not prepared to handle this and would likely crash. Use ostree_checksum_bytes_peek_validate() instead, which sets a GError on an invalid checksum.
This commit is contained in:
1 parent
45cee1bd70
commit
5307af5a7a
3 files changed
+59
-17
No files matched your search
@@ -633,10 +633,15 @@ ostree_repo_remote_list_refs (OstreeRepo *self,
|
||||
|
||||
if (ref_name != NULL)
|
||||
{
|
||||
const guchar *csum_bytes;
|
||||
|
||||
g_variant_get_child (child, 1, "(t@aya{sv})", NULL, &csum_v, NULL);
|
||||
csum_bytes = ostree_checksum_bytes_peek_validate (csum_v, error);
|
||||
if (csum_bytes == NULL)
|
||||
goto out;
|
||||
|
||||
ostree_checksum_inplace_from_bytes (csum_bytes, tmp_checksum);
|
||||
|
||||
ostree_checksum_inplace_from_bytes (ostree_checksum_bytes_peek (csum_v),
|
||||
tmp_checksum);
|
||||
g_hash_table_insert (ret_all_refs,
|
||||
g_strdup (ref_name),
|
||||
g_strdup (tmp_checksum));
|
||||
|
||||
Reference in new issue
Block a user