From d5b2cec0e7d50ee64592c45b72004992a5315ef9 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 7 May 2025 11:44:28 +0200 Subject: [PATCH] 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 --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index c06d0d1..917d562 100644 --- a/main.c +++ b/main.c @@ -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;