diff mbox series

BUG: fix SEGV in copy handler if path is not set

Message ID 20250702134627.3161788-1-stefano.babic@swupdate.org
State Accepted
Headers show
Series BUG: fix SEGV in copy handler if path is not set | expand

Commit Message

Stefano Babic July 2, 2025, 1:46 p.m. UTC
If recursive is set, but sw-description requires to copy a single file
and "create-dest" ist set, path is not checked causing SEGV.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
Reported-by: Joshua Bernimoulin <jbernimoulin@gmail.com>
---
 handlers/copy_handler.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c
index 22e19e53..ae7315ca 100644
--- a/handlers/copy_handler.c
+++ b/handlers/copy_handler.c
@@ -314,8 +314,11 @@  static int copy_image_file(struct img_type *img, void *data)
 	recursive = strtobool(dict_get_value(&img->properties, "recursive"));
 	createdest = strtobool(dict_get_value(&img->properties, "create-destination"));
 
-
 	if (createdest) {
+		if (!strlen(base_img->path)) {
+			ERROR("Destination must be created, but no path set");
+			return -EINVAL;
+		}
 		ret = mkpath(recursive ? base_img->path : dirname(base_img->path), 0755);
 		if (ret < 0) {
 			ERROR("I cannot create path %s: %s",