0002-Lua-fix-segfault-in-image-property-handling.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From ee17493d470ae7fd7b34241f263cfa6d790ce1b3 Mon Sep 17 00:00:00 2001
  2. From: Christian Storm <christian.storm@siemens.com>
  3. Date: Tue, 21 May 2019 14:45:51 +0200
  4. Subject: [PATCH] Lua: fix segfault in image property handling
  5. table2image() calls lua_dump_table() with the 'key' parameter being
  6. NULL and the 'img' parameter set. Subsequently, dict_insert_value() is
  7. called with key == NULL if the Lua stack key's type is string or number,
  8. segfaulting SWUpdate.
  9. Signed-off-by: Christian Storm <christian.storm@siemens.com>
  10. Reported-by: Akihiro Suzuki <akihiro27.suzuki@toshiba.co.jp>
  11. Acked-by: Stefano Babic <sbabic@denx.de>
  12. [Backported from: ee17493d470ae7fd7b34241f263cfa6d790ce1b3]
  13. Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
  14. ---
  15. corelib/lua_interface.c | 8 ++++----
  16. 1 file changed, 4 insertions(+), 4 deletions(-)
  17. diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
  18. index d4ebe4a..443f149 100644
  19. --- a/corelib/lua_interface.c
  20. +++ b/corelib/lua_interface.c
  21. @@ -80,11 +80,11 @@ static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const
  22. lua_tostring(L, -1),
  23. lua_tostring(L, -2));
  24. if (img) {
  25. - TRACE("Inserting property %s[%s] = %s",
  26. - key,
  27. - lua_tostring(L, -1),
  28. + TRACE("Inserting property %s = %s",
  29. + key ? key : lua_tostring(L, -1),
  30. lua_tostring(L, -2));
  31. - dict_insert_value(&img->properties, key,
  32. + dict_insert_value(&img->properties,
  33. + key ? key : lua_tostring(L, -1),
  34. lua_tostring(L, -2));
  35. }
  36. break;
  37. --
  38. 2.7.4