diff mbox series

BUG: fix segv if eMMC handler is called from Lua

Message ID 20241016140823.90836-1-stefano.babic@swupdate.org
State Accepted
Headers show
Series BUG: fix segv if eMMC handler is called from Lua | expand

Commit Message

Stefano Babic Oct. 16, 2024, 2:08 p.m. UTC
There is support for chained image/file handler, not for script handler.
The handler should check (as all other script handlers are doing) to
receive a correct structure, else should exit.

This fixes a SEGV because data structure is accessed.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 handlers/emmc_csd_handler.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.34.1
diff mbox series

Patch

diff --git a/handlers/emmc_csd_handler.c b/handlers/emmc_csd_handler.c
index f6e8e2cf..23732cb1 100644
--- a/handlers/emmc_csd_handler.c
+++ b/handlers/emmc_csd_handler.c
@@ -47,6 +47,9 @@  static int emmc_csd_set(struct img_type *img, void *data, bool toggle)
 	struct script_handler_data *script_data = data;
 	char tmpdev[SWUPDATE_GENERAL_STRING_SIZE];

+	if (!script_data)
+		return -EINVAL;
+
 	if (script_data->scriptfn == PREINSTALL)
 		return 0;