diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2001-11-20 15:09:47 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2001-11-20 15:09:47 +0000 |
commit | 1dd1049794d518ac6a9aec2e46727ea9d9685be8 (patch) | |
tree | cb1885ab63770bb2dd57ec7aa7c91b43a84394c0 /deflate.c | |
parent | fix possible buffer overrun (diff) | |
download | w3m-1dd1049794d518ac6a9aec2e46727ea9d9685be8.tar.gz w3m-1dd1049794d518ac6a9aec2e46727ea9d9685be8.zip |
[w3m-dev 02455] some suggestion
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | deflate.c | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/deflate.c b/deflate.c deleted file mode 100644 index 0464cc6..0000000 --- a/deflate.c +++ /dev/null @@ -1,58 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <zlib.h> - -#undef BUFSIZE -#define BUFSIZE 4096 - -int -main(int argc, char **argv) -{ - z_stream s; - FILE *f; - char inbuf[BUFSIZE], outbuf[BUFSIZE]; - int status, flush; - - if (argc > 1) { - f = fopen(argv[1], "rb"); - if (! f) - exit(1); - } else - f = stdin; - - s.zalloc = Z_NULL; - s.zfree = Z_NULL; - s.opaque = Z_NULL; - status = deflateInit(&s, Z_DEFAULT_COMPRESSION); - if (status != Z_OK) - exit(1); - s.avail_in = 0; - s.next_out = outbuf; - s.avail_out = sizeof(outbuf); - flush = Z_NO_FLUSH; - while (1) { - if (s.avail_in == 0) { - s.next_in = inbuf; - s.avail_in = fread(inbuf, 1, sizeof(inbuf), f); - if (s.avail_in < sizeof(inbuf)) - flush = Z_FINISH; - } - status = deflate(&s, flush); - if (status == Z_STREAM_END) { - if (sizeof(outbuf) - s.avail_out) - fwrite(outbuf, 1, sizeof(outbuf) - s.avail_out, stdout); - break; - } - if (status != Z_OK) - exit(1); - if (s.avail_out == 0) { - fwrite(outbuf, 1, sizeof(outbuf), stdout); - s.next_out = outbuf; - s.avail_out = sizeof(outbuf); - } - } - deflateEnd(&s); - fclose(f); - return 0; -} |