commit - a073bc89c4717b3504571c6ec4dc1449ba7325a0
commit + 44afe042d1448936f791a53640222329029f9c80
blob - 28abcdd269f333bc2558d4d7c57e8626c7071b81
blob + 040d9f0a630b117345440c78ae47a6c13b0808a8
--- src/ngircd/conn-zip.c
+++ src/ngircd/conn-zip.c
/* enable more zlib related debug messages: */
/* #define DEBUG_ZLIB */
-static char UNUSED id[] = "$Id: conn-zip.c,v 1.12 2007/05/09 08:55:14 fw Exp $";
+static char UNUSED id[] = "$Id: conn-zip.c,v 1.13 2007/05/17 13:49:49 alex Exp $";
#include "imp.h"
#include <assert.h>
} /* Zip_Buffer */
+/**
+ * Compress data in ZIP buffer and move result to the write buffer of
+ * the connection.
+ * @param Idx Connection handle.
+ * @retrun true on success, false otherwise.
+ */
GLOBAL bool
Zip_Flush( CONN_ID Idx )
{
- /* Daten komprimieren und in Schreibpuffer kopieren.
- * Es wird true bei Erfolg, sonst false geliefert. */
-
int result;
unsigned char zipbuf[WRITEBUFFER_LEN];
int zipbuf_used = 0;
return false;
out->avail_in = (uInt)array_bytes(&My_Connections[Idx].zip.wbuf);
+ if (!out->avail_in)
+ return true; /* nothing to do. */
out->next_out = zipbuf;
out->avail_out = (uInt)sizeof zipbuf;
return false;
}
+ if (out->avail_out <= 0) {
+ /* Not all data was compressed, because data became
+ * bigger while compressing it. */
+ Log (LOG_ALERT, "Compression error: buffer overvlow!?");
+ Conn_Close(Idx, "Compression error!", NULL, false);
+ return false;
+ }
+
assert(out->avail_out <= WRITEBUFFER_LEN);
- assert(out->avail_out > 0); /* 0 might indicate not all data was compressed... */
+
zipbuf_used = WRITEBUFFER_LEN - out->avail_out;
#ifdef DEBUG_ZIP
Log(LOG_DEBUG, "zipbuf_used: %d", zipbuf_used);