*/
#include <stdlib.h>
+#include <string.h>
#include <assert.h>
#ifdef ZLIB_STANDALONE
struct Match defermatch, matches[MAXMATCH];
int deferchr;
+ assert(st->npending <= HASHCHARS);
+
/*
* Add any pending characters from last time to the window. (We
* might not be able to.)
+ *
+ * This leaves st->pending empty in the usual case (when len >=
+ * HASHCHARS); otherwise it leaves st->pending empty enough that
+ * adding all the remaining 'len' characters will not push it past
+ * HASHCHARS in size.
*/
for (i = 0; i < st->npending; i++) {
unsigned char foo[HASHCHARS];
}
st->npending -= i;
+ defermatch.distance = 0; /* appease compiler */
defermatch.len = 0;
deferchr = '\0';
while (len > 0) {
if (len >= HASHCHARS) {
lz77_advance(st, *data, lz77_hash(data));
} else {
+ assert(st->npending < HASHCHARS);
st->pending[st->npending++] = *data;
}
data++;
/*
* Start a Deflate (RFC1951) uncompressed block. We
- * transmit a zero bit (BFINAL=0), followed by a zero
- * bit and a one bit (BTYPE=00). Of course these are in
- * the wrong order (00 0).
+ * transmit a zero bit (BFINAL=0), followed by two more
+ * zero bits (BTYPE=00). Of course these are in the
+ * wrong order (00 0), not that it matters.
*/
outbits(out, 0, 3);
goto finished;
if (code == -2)
goto decode_error;
+ if (code >= 30) /* dist symbols 30 and 31 are invalid */
+ goto decode_error;
dctx->state = GOTDISTSYM;
dctx->sym = code;
break;
goto finished;
nlen = dctx->bits & 0xFFFF;
EATBITS(16);
+ if (dctx->uncomplen != (nlen ^ 0xFFFF))
+ goto decode_error;
if (dctx->uncomplen == 0)
dctx->state = OUTSIDEBLK; /* block is empty */
else
const struct ssh_compress ssh_zlib = {
"zlib",
+ "zlib@openssh.com", /* delayed version */
zlib_compress_init,
zlib_compress_cleanup,
zlib_compress_block,