aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-04-13 12:20:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-04-13 12:20:51 +0100
commit592ededbbef6bcff2031b112b510d559008510e9 (patch)
tree3e911dd73a9ddcf808a72512de41451d66bbea38
parent250119fd00a59a9e90ffe3336324a68f1c3407f6 (diff)
downloadrspamd-592ededbbef6bcff2031b112b510d559008510e9.tar.gz
rspamd-592ededbbef6bcff2031b112b510d559008510e9.zip
[Minor] Improve log message for inflate/deflate
-rw-r--r--src/lua/lua_util.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index a378c1ace..d89cfd28d 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -2321,7 +2321,8 @@ lua_util_gzip_compress (lua_State *L)
break;
}
else {
- msg_err ("cannot compress data: %s", zError (rc));
+ msg_err ("cannot compress data: %s (last error: %s)",
+ zError (rc), strm.msg);
lua_pop (L, 1); /* Text will be freed here */
lua_pushnil (L);
deflateEnd (&strm);
@@ -2388,6 +2389,15 @@ lua_util_zlib_inflate (lua_State *L, int windowBits)
memset (&strm, 0, sizeof (strm));
/* windowBits +16 to decode gzip, zlib 1.2.0.4+ */
+
+ /* Here are dragons to distinguish between raw deflate and zlib */
+ if (windowBits == MAX_WBITS && t->len > 0) {
+ if ((int)(unsigned char)t->start[0] != 0x78) {
+ /* Assume raw deflate */
+ windowBits = -windowBits;
+ }
+ }
+
rc = inflateInit2 (&strm, windowBits);
if (rc != Z_OK) {
@@ -2416,7 +2426,8 @@ lua_util_zlib_inflate (lua_State *L, int windowBits)
break;
}
else {
- msg_err ("cannot decompress data: %s", zError (rc));
+ msg_err ("cannot decompress data: %s (last error: %s)",
+ zError (rc), strm.msg);
lua_pop (L, 1); /* Text will be freed here */
lua_pushnil (L);
inflateEnd (&strm);