From 36ba8404895627ee55125edddd6686acda45fa2d Mon Sep 17 00:00:00 2001 From: nnposter Date: Sat, 7 Sep 2024 16:40:14 +0000 Subject: [PATCH] Fix broken loading of SSH public keys from a file. Close #2919, see #2917 --- nse_libssh2.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nse_libssh2.cc b/nse_libssh2.cc index 4ac23be70..fe70b2e55 100644 --- a/nse_libssh2.cc +++ b/nse_libssh2.cc @@ -553,6 +553,11 @@ static int l_read_publickey (lua_State *L) { const char* publickeyfile = luaL_checkstring(L, 1); luaL_Buffer publickey_data; + lua_getglobal(L, "require"); + lua_pushliteral(L, "base64"); + lua_call(L, 1, 1); + lua_getfield(L, -1, "dec"); + fd = fopen(publickeyfile, "r"); if (!fd) return luaL_error(L, "Error reading file"); @@ -566,11 +571,6 @@ static int l_read_publickey (lua_State *L) { } fclose(fd); - lua_getglobal(L, "require"); - lua_pushstring(L, "base64"); - lua_call(L, 1, 1); - lua_getfield(L, -1, "dec"); - luaL_pushresult(&publickey_data); lua_call(L, 1, 1);