From f72573a2aaac0c642d2f47a40ee32b6fdb76ef26 Mon Sep 17 00:00:00 2001 From: liaodaiguo123 Date: Thu, 31 Mar 2022 18:57:03 +0800 Subject: [PATCH] base64:To improve compatibility, there may not be enough equal signs (#1561) --- lualib-src/lua-crypt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lualib-src/lua-crypt.c b/lualib-src/lua-crypt.c index 0e4d06cf..a287715e 100644 --- a/lualib-src/lua-crypt.c +++ b/lualib-src/lua-crypt.c @@ -961,10 +961,12 @@ lb64decode(lua_State *L) { int padding = 0; int c[4]; for (j=0;j<4;) { - if (i>=sz) { - return luaL_error(L, "Invalid base64 text"); + if (i>=sz && 4>j){ + /*To improve compatibility, there may not be enough equal signs */ + c[j] = -2; + }else{ + c[j] = b64index(text[i]); } - c[j] = b64index(text[i]); if (c[j] == -1) { ++i; continue;