blob: 5577547d8c83013569e81802154a354671633be5 [file] [log] [blame]
From ee17493d470ae7fd7b34241f263cfa6d790ce1b3 Mon Sep 17 00:00:00 2001
From: Christian Storm <christian.storm@siemens.com>
Date: Tue, 21 May 2019 14:45:51 +0200
Subject: [PATCH] Lua: fix segfault in image property handling
table2image() calls lua_dump_table() with the 'key' parameter being
NULL and the 'img' parameter set. Subsequently, dict_insert_value() is
called with key == NULL if the Lua stack key's type is string or number,
segfaulting SWUpdate.
Signed-off-by: Christian Storm <christian.storm@siemens.com>
Reported-by: Akihiro Suzuki <akihiro27.suzuki@toshiba.co.jp>
Acked-by: Stefano Babic <sbabic@denx.de>
[Backported from: ee17493d470ae7fd7b34241f263cfa6d790ce1b3]
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
---
corelib/lua_interface.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index d4ebe4a..443f149 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -80,11 +80,11 @@ static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const
lua_tostring(L, -1),
lua_tostring(L, -2));
if (img) {
- TRACE("Inserting property %s[%s] = %s",
- key,
- lua_tostring(L, -1),
+ TRACE("Inserting property %s = %s",
+ key ? key : lua_tostring(L, -1),
lua_tostring(L, -2));
- dict_insert_value(&img->properties, key,
+ dict_insert_value(&img->properties,
+ key ? key : lua_tostring(L, -1),
lua_tostring(L, -2));
}
break;
--
2.7.4