diff mbox series

Lua: transport sha256 field to Lua

Message ID 20171002141938.20962-1-christian.storm@siemens.com
State Accepted
Headers show
Series Lua: transport sha256 field to Lua | expand

Commit Message

Storm, Christian Oct. 2, 2017, 2:19 p.m. UTC
table2image() respects the sha256 field (via lua_string_to_img)
but image2table() does not. Add it to image2table().

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 corelib/lua_interface.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Stefano Babic Oct. 3, 2017, 8:43 a.m. UTC | #1
On 02/10/2017 16:19, Christian Storm wrote:
> table2image() respects the sha256 field (via lua_string_to_img)
> but image2table() does not. Add it to image2table().
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/lua_interface.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
> index e190ebf..a80f6a0 100644
> --- a/corelib/lua_interface.c
> +++ b/corelib/lua_interface.c
> @@ -265,6 +265,11 @@ static void image2table(lua_State* L, struct img_type *img) {
>  		LUA_PUSH_IMG_NUMBER(img, "size", size);
>  		LUA_PUSH_IMG_NUMBER(img, "checksum", checksum);
>  
> +		char *hashstring = alloca(2 * SHA256_HASH_LENGTH + 1);
> +		hash_to_ascii(img->sha256, hashstring);
> +		lua_pushstring(L, "sha256");
> +		lua_pushstring(L, hashstring);
> +		lua_settable(L, -3);
>  	}
>  }
>  
> 

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index e190ebf..a80f6a0 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -265,6 +265,11 @@  static void image2table(lua_State* L, struct img_type *img) {
 		LUA_PUSH_IMG_NUMBER(img, "size", size);
 		LUA_PUSH_IMG_NUMBER(img, "checksum", checksum);
 
+		char *hashstring = alloca(2 * SHA256_HASH_LENGTH + 1);
+		hash_to_ascii(img->sha256, hashstring);
+		lua_pushstring(L, "sha256");
+		lua_pushstring(L, hashstring);
+		lua_settable(L, -3);
 	}
 }