libsysprof: be more defensive against oddly formed containers

If we get a container file that is in a format we don't quite understand,
avoid crashing and just bail. That will likely result in the inability
to symbolize properly, but better than crashing.

Fixes #100
This commit is contained in:
Christian Hergert
2023-09-26 17:27:17 -07:00
parent ab4e7ab509
commit 37c2a527b4

View File

@ -252,18 +252,24 @@ sysprof_podman_get_layers (SysprofPodman *self,
layers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
/* Add all our known layers starting from current layer */
do
g_hash_table_add (layers, get_layer_dir (layer));
while ((layer = find_parent_layer (self->layers_parser, layer, layers)));
/* If an image was specified, add its layer */
if ((layer = find_image_layer (self->images_parser, image)))
if (layer != NULL)
{
do
g_hash_table_add (layers, get_layer_dir (layer));
while ((layer = find_parent_layer (self->layers_parser, layer, layers)));
}
/* If an image was specified, add its layer */
if (image != NULL)
{
if ((layer = find_image_layer (self->images_parser, image)))
{
do
g_hash_table_add (layers, get_layer_dir (layer));
while ((layer = find_parent_layer (self->layers_parser, layer, layers)));
}
}
keys = (const char **)g_hash_table_get_keys_as_array (layers, NULL);
ret = g_strdupv ((char **)keys);