diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-04 18:12:03 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-04 18:12:03 +0000 |
commit | 185e8e1239cfd0db4dbe048e1bab2a3e8561edbb (patch) | |
tree | 934eabab06313d64ff1dec078016fd06f43427d6 /src/lua | |
parent | 94aa6a01238cf6ebae30b63c5afcc78756251a31 (diff) | |
download | rspamd-185e8e1239cfd0db4dbe048e1bab2a3e8561edbb.tar.gz rspamd-185e8e1239cfd0db4dbe048e1bab2a3e8561edbb.zip |
[Project] Improve inflation
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_util.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c index d915085fc..ae1a020a1 100644 --- a/src/lua/lua_util.c +++ b/src/lua/lua_util.c @@ -2356,9 +2356,15 @@ lua_util_zlib_inflate (lua_State *L, int windowBits) if (lua_type (L, 2) == LUA_TNUMBER) { size_limit = lua_tointeger (L, 2); - } + if (size_limit <= 0) { + return luaL_error (L, "invalid arguments (size_limit)"); + } - sz = t->len; + sz = MIN (t->len * 2, size_limit); + } + else { + sz = t->len * 2; + } memset (&strm, 0, sizeof (strm)); /* windowBits +16 to decode gzip, zlib 1.2.0.4+ */ @@ -2436,7 +2442,7 @@ lua_util_gzip_decompress (lua_State *L) static gint lua_util_inflate (lua_State *L) { - return lua_util_zlib_inflate (L, 0); + return lua_util_zlib_inflate (L, MAX_WBITS); } static gint |