--- pgp/src/ztrees.c 2018/04/24 16:37:54 1.1 +++ pgp/src/ztrees.c 2018/04/24 16:45:52 1.1.1.6 @@ -278,8 +278,8 @@ local ulg compressed_len; /* total bit l local ulg input_len; /* total byte length of input file */ /* input_len is for debugging only since we can get it by other means. */ -ush *file_type; /* pointer to UNKNOWN, BINARY or ASCII */ -int *file_method; /* pointer to DEFLATE or STORE */ +static ush *file_type; /* pointer to UNKNOWN, BINARY or ASCII */ +static int *file_method; /* pointer to DEFLATE or STORE */ #ifdef DEBUG extern ulg bits_sent; /* bit length of the compressed data */ @@ -331,9 +331,9 @@ local void set_file_type OF((void)); * location of the internal file attribute (ascii/binary) and method * (DEFLATE/STORE). */ -void ct_init(attr, method) +void ct_init(attr, Method) ush *attr; /* pointer to internal file attribute */ - int *method; /* pointer to compression method */ + int *Method; /* pointer to compression method */ { int n; /* iterates over tree elements */ int bits; /* bit counter */ @@ -342,11 +342,9 @@ void ct_init(attr, method) int dist; /* distance index */ file_type = attr; - file_method = method; + file_method = Method; compressed_len = input_len = 0L; - if (static_dtree[0].Len != 0) return; /* ct_init already called */ - #ifdef DYN_ALLOC d_buf = (ush far*) fcalloc(DIST_BUFSIZE, sizeof(ush)); l_buf = (uch far*) fcalloc(LIT_BUFSIZE/2, 2); @@ -354,6 +352,8 @@ void ct_init(attr, method) if (l_buf == NULL || d_buf == NULL) error("ct_init: out of memory"); #endif + if (static_dtree[0].Len != 0) return; /* ct_init already called */ + /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { @@ -410,6 +410,21 @@ void ct_init(attr, method) init_block(); } +void ct_free() +{ +#ifdef DYN_ALLOC +#ifndef __TURBOC__ /*EWS*/ + fcfree(d_buf); + fcfree(l_buf); +#else + free(d_buf); + free(l_buf); +#endif + d_buf = NULL; + l_buf = NULL; +#endif +} + /* =========================================================================== * Initialize a new block. */ @@ -920,7 +935,7 @@ ulg flush_block(buf, stored_len, eof) #ifdef FORCE_METHOD if (level == 2 && buf != NULL) { /* force stored block */ #else - if (stored_len+4 <= opt_lenb && buf != NULL) { + if ((stored_len+4 <= opt_lenb) && (buf != (char *)NULL)) { /* 4: two words for the lengths */ #endif /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. @@ -953,7 +968,19 @@ ulg flush_block(buf, stored_len, eof) init_block(); if (eof) { +#ifndef ZIP + /* Wipe out sensitive data for pgp */ +# ifdef DYN_ALLOC + extern uch *slide; +# else + extern uch slide[]; +# endif + memset(slide, 0, (unsigned)(2*WSIZE-1)); /* -1 needed if WSIZE=32K */ +#endif /* ZIP */ + +#if 0 Assert (input_len == isize, "bad input size"); +#endif bi_windup(); compressed_len += 7; /* align on byte boundary */ }