main: fix layer lookup in make_ovl_node

Stop iterating through layers in `make_ovl_node`
if the current layer being checked is the `last_layer`
of the parent node.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2025-05-07 11:44:28 +02:00
parent 28ba1fd247
commit d5b2cec0e7
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772

6
main.c
View File

@ -1526,6 +1526,7 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
struct ovl_layer *it;
cleanup_free char *npath = NULL;
char whiteout_path[PATH_MAX];
bool stop_lookup = false;
npath = strdup (ret->path);
if (npath == NULL)
@ -1536,13 +1537,16 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
else
strconcat3 (whiteout_path, PATH_MAX, "/.wh.", name, NULL);
for (it = layer; it; it = it->next)
for (it = layer; it && ! stop_lookup; it = it->next)
{
ssize_t s;
cleanup_free char *val = NULL;
cleanup_free char *origin = NULL;
cleanup_close int fd = -1;
if (parent && parent->last_layer == it)
stop_lookup = true;
if (dir_p)
{
int r;