Skip to content

Commit d53fc0c

Browse files
committed
(sigh!) CORRECTLY fix hetlib.c bug...
... WITHOUT also breaking ZLIB!
1 parent 91e1348 commit d53fc0c

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

hetlib.c

+26-6
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,14 @@ het_read( HETB *hetb, void *sbuf )
767767
{
768768
char *tptr;
769769
int rc;
770-
unsigned int slen;
770+
771+
unsigned long slen;
772+
unsigned long tlen;
773+
774+
unsigned int bz_slen;
775+
unsigned int bz_tlen;
776+
771777
int flags1, flags2;
772-
unsigned int tlen;
773778
char *tbuf;
774779

775780
/*
@@ -963,14 +968,21 @@ het_read( HETB *hetb, void *sbuf )
963968

964969
#if defined( HET_BZIP2 )
965970
case HETHDR_FLAGS1_BZLIB:
971+
966972
slen = HETMAX_BLOCKSIZE;
967973

974+
bz_slen = (unsigned int) slen;
975+
bz_tlen = (unsigned int) tlen;
976+
968977
rc = BZ2_bzBuffToBuffDecompress( sbuf,
969-
(void *) &slen,
978+
(void *) &bz_slen,
970979
tbuf,
971-
tlen,
980+
bz_tlen,
972981
0,
973982
0 );
983+
slen = (unsigned long) bz_slen;
984+
tlen = (unsigned long) bz_tlen;
985+
974986
if (rc != BZ_OK)
975987
{
976988
rc = errno;
@@ -1254,7 +1266,11 @@ het_write( HETB *hetb, const void *sbuf, int slen )
12541266
{
12551267
int rc;
12561268
int flags;
1257-
unsigned int tlen;
1269+
1270+
unsigned long tlen;
1271+
1272+
unsigned int bz_tlen;
1273+
12581274
char *tbuf = NULL;
12591275
#if defined( HAVE_ZLIB ) || defined( HET_BZIP2 )
12601276
size_t tsiz = ((((HETMAX_BLOCKSIZE * 1001) + 999) / 1000) + 12);
@@ -1317,13 +1333,17 @@ het_write( HETB *hetb, const void *sbuf, int slen )
13171333
case HETHDR_FLAGS1_BZLIB:
13181334
tlen = tsiz;
13191335

1336+
bz_tlen = (unsigned int) tlen;
1337+
13201338
rc = BZ2_bzBuffToBuffCompress( tbuf,
1321-
(void *) &tlen,
1339+
(void *) &bz_tlen,
13221340
(void *)sbuf,
13231341
slen,
13241342
hetb->level,
13251343
0,
13261344
0 );
1345+
tlen = (unsigned long) bz_tlen;
1346+
13271347
if( rc != BZ_OK )
13281348
{
13291349
rc = errno;

0 commit comments

Comments
 (0)