X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fextra%2Fm_ziplink.cpp;h=ab40acb46556514faa9c7241622db6ca048523a3;hb=59bd18f2a0b43b71ee32124add9d40d1d3a54919;hp=479eaa12ede87972124827276b7e4ecdc1beda9c;hpb=d92a8cde88d6d119fa10ca52cf7f802a60323931;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp index 479eaa12e..ab40acb46 100644 --- a/src/modules/extra/m_ziplink.cpp +++ b/src/modules/extra/m_ziplink.cpp @@ -2,21 +2,15 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * - * - * Written by Craig Edwards, Craig McLure, and others. + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ -#include -#include - #include "zlib.h" #include "inspircd_config.h" @@ -318,6 +312,7 @@ class ModuleZLib : public Module { /* Add it to the frame queue */ session->inbuf->AddData(compr, readresult); + total_in_compressed += readresult; /* Parse all completed frames */ int size = 0; @@ -327,8 +322,9 @@ class ModuleZLib : public Module session->d_stream.avail_in = 0; session->d_stream.next_out = (Bytef*)(buffer + offset); + /* If we cant call this, well, we're boned. */ if (inflateInit(&session->d_stream) != Z_OK) - return -EBADF; + return 0; while ((session->d_stream.total_out < count) && (session->d_stream.total_in < (unsigned int)size)) { @@ -337,15 +333,19 @@ class ModuleZLib : public Module break; } + /* Stick a fork in me, i'm done */ inflateEnd(&session->d_stream); - total_in_compressed += readresult; + /* Update counters and offsets */ total_size += session->d_stream.total_out; total_in_uncompressed += session->d_stream.total_out; offset += session->d_stream.total_out; } + /* Null-terminate the buffer -- this doesnt harm binary data */ buffer[total_size] = 0; + + /* Set the read size to the correct total size */ readresult = total_size; } @@ -443,7 +443,7 @@ class ModuleZLib : public Module void CloseSession(izip_session* session) { - if (session->status = IZIP_OPEN) + if (session->status == IZIP_OPEN) { session->status = IZIP_CLOSED; session->outbuf = "";