lib: Check for NULL pointers in some more places

In `write_metadata_object()`, make sure when creating tombstone commits
that we're actually passed an expected checksum to use.

In `write_dir_entry_to_mtree_internal()`, sanity check that `dfd_iter`
is indeed not `NULL` before trying to dereference it.

Discovered by Coverity.

Closes: #1692
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2018-07-25 17:45:51 -04:00 committed by Atomic Bot
parent 799cfcb5b3
commit 9482922e5e

View File

@ -1295,6 +1295,7 @@ write_metadata_object (OstreeRepo *self,
char actual_checksum[OSTREE_SHA256_STRING_LEN+1];
if (is_tombstone)
{
g_assert (expected_checksum != NULL);
memcpy (actual_checksum, expected_checksum, sizeof (actual_checksum));
}
else
@ -3309,6 +3310,7 @@ write_dir_entry_to_mtree_internal (OstreeRepo *self,
}
else
{
g_assert (dfd_iter != NULL);
g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
if (!glnx_dirfd_iterator_init_at (dfd_iter->fd, name, FALSE, &child_dfd_iter, error))