cvs: php4 /ext/zlib zlib.c

From: Date: Fri, 13 Jul 2001 15:19:17 +0000
Subject: cvs: php4 /ext/zlib zlib.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6209@lists.php.net to get a copy of this message
thies Fri Jul 13 11:19:17 2001 EDT Modified files: /php4/ext/zlib zlib.c Log: fixed #12091. added \0 bytes at EOS in a few cases. Index: php4/ext/zlib/zlib.c diff -u php4/ext/zlib/zlib.c:1.81 php4/ext/zlib/zlib.c:1.82 --- php4/ext/zlib/zlib.c:1.81 Wed Jul 11 11:26:42 2001 +++ php4/ext/zlib/zlib.c Fri Jul 13 11:19:17 2001 @@ -16,7 +16,7 @@ | Stefan Röhrich <sr@linux.de> | +----------------------------------------------------------------------+ */ -/* $Id: zlib.c,v 1.81 2001/07/11 15:26:42 thies Exp $ */ +/* $Id: zlib.c,v 1.82 2001/07/13 15:19:17 thies Exp $ */ #define IS_EXT_MODULE #ifdef HAVE_CONFIG_H @@ -874,7 +874,7 @@ stream.next_in = (Bytef*) (*data)->value.str.val; stream.avail_in = (*data)->value.str.len; - stream.avail_out = stream.avail_in + (stream.avail_in/1000) + 15; + stream.avail_out = stream.avail_in + (stream.avail_in/1000) + 15 + 1; /* room for \0 */ s2 = (char *) emalloc(stream.avail_out); if(!s2) RETURN_FALSE; stream.next_out = s2; @@ -894,7 +894,9 @@ } } - if(status==Z_OK) { + if (status==Z_OK) { + s2 = erealloc(s2,stream.total_out+1); /* resize to buffer to the "right" size */ + s2[ stream.total_out ] = '\0'; RETURN_STRINGL(s2, stream.total_out, 0); } else { efree(s2); @@ -909,7 +911,7 @@ PHP_FUNCTION(gzinflate) { zval **data, **zlimit = NULL; - int status,factor=1,maxfactor=8; + int status,factor=1,maxfactor=16; unsigned long plength=0,length; char *s1=NULL,*s2=NULL; z_stream stream; @@ -938,10 +940,11 @@ /* stream.avail_out wants to know the output data length if none was given as a parameter - we try from input length * 2 up to input length * 2^8 + we try from input length * 2 up to input length * 2^16 doubling it whenever it wasn't big enough that should be enaugh for all real life cases */ + stream.zalloc = (alloc_func) Z_NULL; stream.zfree = (free_func) Z_NULL; @@ -974,7 +977,8 @@ } while((status==Z_BUF_ERROR)&&(!plength)&&(factor<maxfactor)); if(status==Z_OK) { - s2 = erealloc(s2, stream.total_out); + s2 = erealloc(s2, stream.total_out + 1); /* room for \0 */ + s2[ stream.total_out ] = '\0'; RETURN_STRINGL(s2, stream.total_out, 0); } else { efree(s2);

« previous php.cvs (#6209) next »