[WATCHDOG] Use DIV_ROUND_UP() macro in the coh901327 WDT
[safe/jmp/linux-2.6] / lib / decompress_inflate.c
index 163e66a..68dfce5 100644 (file)
 #include "zlib_inflate/inflate.h"
 
 #include "zlib_inflate/infutil.h"
+#include <linux/slab.h>
 
 #endif /* STATIC */
 
 #include <linux/decompress/mm.h>
 
-#define INBUF_LEN (16*1024)
+#define GZIP_IOBUF_SIZE (16*1024)
 
 /* Included from initramfs et al code */
 STATIC int INIT gunzip(unsigned char *buf, int len,
@@ -41,7 +42,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
        set_error_fn(error_fn);
        rc = -1;
        if (flush) {
-               out_len = 0x8100; /* 32 K */
+               out_len = 0x8000; /* 32 K */
                out_buf = malloc(out_len);
        } else {
                out_len = 0x7fffffff; /* no limit */
@@ -54,7 +55,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
        if (buf)
                zbuf = buf;
        else {
-               zbuf = malloc(INBUF_LEN);
+               zbuf = malloc(GZIP_IOBUF_SIZE);
                len = 0;
        }
        if (!zbuf) {
@@ -76,7 +77,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
        }
 
        if (len == 0)
-               len = fill(zbuf, INBUF_LEN);
+               len = fill(zbuf, GZIP_IOBUF_SIZE);
 
        /* verify the gzip header */
        if (len < 10 ||
@@ -97,7 +98,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
                        strm->next_in++;
                strm->next_in++;
        }
-       strm->avail_in = len - 10;
+       strm->avail_in = len - (strm->next_in - zbuf);
 
        strm->next_out = out_buf;
        strm->avail_out = out_len;
@@ -112,7 +113,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
        while (rc == Z_OK) {
                if (strm->avail_in == 0) {
                        /* TODO: handle case where both pos and fill are set */
-                       len = fill(zbuf, INBUF_LEN);
+                       len = fill(zbuf, GZIP_IOBUF_SIZE);
                        if (len < 0) {
                                rc = -1;
                                error("read error");