mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
repofile: Avoid segfault if querying child in non-directory
The user might "ostree ls /usr/bin/bash/blah", which previously would segfault. A somewhat related future enhancement here would be for "ostree ls" to follow symbolic links. Reported-by: Dusty Mabe <dustymabe@gmail.com> https://bugzilla.gnome.org/show_bug.cgi?id=733476
This commit is contained in:
parent
e392820541
commit
cdaa9517af
@ -223,6 +223,13 @@ do_resolve_nonroot (OstreeRepoFile *self,
|
||||
if (!ostree_repo_file_ensure_resolved (self->parent, error))
|
||||
goto out;
|
||||
|
||||
if (!self->parent->tree_contents)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY,
|
||||
"Not a directory");
|
||||
goto out;
|
||||
}
|
||||
|
||||
i = ostree_repo_file_tree_find_child (self->parent, self->name, &is_dir, &container);
|
||||
|
||||
if (i < 0)
|
||||
|
@ -267,6 +267,13 @@ cd ${test_tmpdir}
|
||||
$OSTREE ls test2
|
||||
echo "ok ls with no argument"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
if $OSTREE ls test2 /baz/cow/notadir 2>errmsg; then
|
||||
assert_not_reached
|
||||
fi
|
||||
assert_file_has_content errmsg "Not a directory"
|
||||
echo "ok ls of not a directory"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
$OSTREE show test2
|
||||
echo "ok show with non-checksum"
|
||||
|
Loading…
x
Reference in New Issue
Block a user