diff mbox series

[1/1] lua: fix segfault in properties

Message ID 1545715596-20921-1-git-send-email-james.hilliard1@gmail.com
State Not Applicable
Headers show
Series [1/1] lua: fix segfault in properties | expand

Commit Message

James Hilliard Dec. 25, 2018, 5:26 a.m. UTC
From: James Hilliard <james.hilliard1@gmail.com>

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 corelib/lua_interface.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

James Hilliard Dec. 25, 2018, 5:38 a.m. UTC | #1
Without this fix I get this error:
[TRACE] : SWUPDATE running :  [LUAstackDump] : (1) [bool  ] true
ANOM_ABEND auid=4294967295 uid=0 gid=0 ses=4294967295 subj=kernel
pid=2130 comm="swupdate" exe="/usr/bin/swupdate" sig=11 res=1
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] encrypted = false
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] size = 0.0
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] partition = false
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] compressed = false
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] path = /
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] type = archive
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] data =
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] version =
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] volume =
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] filesystem = ext4
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] device =
/dev/disk/by-partlabel/main
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] script = false
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ]
properties: create-destination = true
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] sha256 =
8509994789747eaf812f8beb0112e33b26dd367df291f18bdcab23c81c955b0b
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] checksum = 0.0
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] mtdname = /
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] filename
= rootfs.tar.xz
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] name =
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ]
install_if_different = false
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ] offset = 0.0
[TRACE] : SWUPDATE running :  [lua_dump_table] : (2) [table ]
installed_directly = false
[TRACE] : SWUPDATE running :  [lua_dump_table] : properties
create-destination = true
[TRACE] : SWUPDATE running :  [lua_dump_table] : Inserting property
(null)[create-destination] = true
show_signal_msg: 2 callbacks suppressed
swupdate[2199]: segfault at 0 ip 00007f5108f25686 sp 00007f51063a72e8
error 4 in libc-2.28.so[7f5108e91000+1ab000]
Code: 0f 1f 40 00 66 0f ef c0 66 0f ef c9 66 0f ef d2 66 0f ef db 48
89 f8 48 89 f9 48 81 e1 ff 0f 00 00 48 81 f9 cf 0f 00 00 77 6a <f3> 0f
6f 20 66 0f 74 e0 66 0f d7 d4 85 d2 74 04 0f bc c2 c3 48 83
audit: type=1701 audit(1545701746.447:6): auid=4294967295 uid=0 gid=0
ses=4294967295 subj=kernel pid=2130 comm="swupdate"
exe="/usr/bin/swupdate" sig=11 res=1
swupdate.service: Main process exited, code=killed, status=11/SEGV

On Mon, Dec 24, 2018 at 11:26 PM <james.hilliard1@gmail.com> wrote:
>
> From: James Hilliard <james.hilliard1@gmail.com>
>
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
>  corelib/lua_interface.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
> index d4ebe4a..391d6b3 100644
> --- a/corelib/lua_interface.c
> +++ b/corelib/lua_interface.c
> @@ -64,7 +64,7 @@ static bool is_type(lua_State *L, uintptr_t type)
>  }
>  #endif
>
> -static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const char *key)
> +static void lua_dump_table(lua_State *L, char *str, struct img_type *img)
>  {
>         /* Stack: table, ... */
>         lua_pushnil(L);
> @@ -81,10 +81,11 @@ static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const
>                                         lua_tostring(L, -2));
>                                 if (img) {
>                                         TRACE("Inserting property %s[%s] = %s",
> -                                                       key,
> +                                                       str,
>                                                         lua_tostring(L, -1),
>                                                         lua_tostring(L, -2));
> -                                       dict_insert_value(&img->properties, key,
> +                                       dict_insert_value(&img->properties,
> +                                                       str,
>                                                         lua_tostring(L, -2));
>                                 }
>                                 break;
> @@ -103,7 +104,7 @@ static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const
>
>                                 if (asprintf(&s, "%s %s:", str, propkey) != ENOMEM_ASPRINTF) {
>                                         lua_pushvalue(L, -2);
> -                                       lua_dump_table(L, s, img, propkey);
> +                                       lua_dump_table(L, s, img);
>                                         lua_pop(L, 1);
>                                         free(s);
>                                 }
> @@ -155,7 +156,7 @@ void LUAstackDump(lua_State *L)
>
>                                 if (asprintf(&s, "(%d) [table ]", i) != ENOMEM_ASPRINTF) {
>                                         lua_pushvalue(L, -1);
> -                                       lua_dump_table(L, s, NULL, NULL);
> +                                       lua_dump_table(L, s, NULL);
>                                         lua_pop(L, 1);
>                                         free(s);
>                                 }
> @@ -592,7 +593,7 @@ static void table2image(lua_State* L, struct img_type *img) {
>                                         if (!strcmp (lua_tostring(L, -2), "properties")) {
>                                                 dict_drop_db(&img->properties);
>                                                 lua_pushvalue(L, -1);
> -                                               lua_dump_table(L, (char*)"properties", img, NULL);
> +                                               lua_dump_table(L, (char*)"properties", img);
>                                                 lua_pop(L, 1);
>                                         }
>                                         break;
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index d4ebe4a..391d6b3 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -64,7 +64,7 @@  static bool is_type(lua_State *L, uintptr_t type)
 }
 #endif
 
-static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const char *key)
+static void lua_dump_table(lua_State *L, char *str, struct img_type *img)
 {
 	/* Stack: table, ... */
 	lua_pushnil(L);
@@ -81,10 +81,11 @@  static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const
 					lua_tostring(L, -2));
 				if (img) {
 					TRACE("Inserting property %s[%s] = %s",
-							key,
+							str,
 							lua_tostring(L, -1),
 							lua_tostring(L, -2));
-					dict_insert_value(&img->properties, key,
+					dict_insert_value(&img->properties,
+							str,
 							lua_tostring(L, -2));
 				}
 				break;
@@ -103,7 +104,7 @@  static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const
 
 				if (asprintf(&s, "%s %s:", str, propkey) != ENOMEM_ASPRINTF) {
 					lua_pushvalue(L, -2);
-					lua_dump_table(L, s, img, propkey);
+					lua_dump_table(L, s, img);
 					lua_pop(L, 1);
 					free(s);
 				}
@@ -155,7 +156,7 @@  void LUAstackDump(lua_State *L)
 
 				if (asprintf(&s, "(%d) [table ]", i) != ENOMEM_ASPRINTF) {
 					lua_pushvalue(L, -1);
-					lua_dump_table(L, s, NULL, NULL);
+					lua_dump_table(L, s, NULL);
 					lua_pop(L, 1);
 					free(s);
 				}
@@ -592,7 +593,7 @@  static void table2image(lua_State* L, struct img_type *img) {
 					if (!strcmp (lua_tostring(L, -2), "properties")) {
 						dict_drop_db(&img->properties);
 						lua_pushvalue(L, -1);
-						lua_dump_table(L, (char*)"properties", img, NULL);
+						lua_dump_table(L, (char*)"properties", img);
 						lua_pop(L, 1);
 					}
 					break;