From: Greg Beaver Date: Fri, 5 Jan 2007 01:13:13 +0000 (+0000) Subject: fixed crc - write test works X-Git-Tag: RELEASE_1_0_0RC1~402 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=10d45c76686139b07486639582b77ffadebf117f;p=php fixed crc - write test works --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index d66b4dab8b..bbbf069090 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1470,7 +1470,8 @@ static int phar_flush(php_stream *stream TSRMLS_DC) /* {{{ */ char *manifest; off_t manifest_ftell, bufsize; long offset; - php_uint32 copy, loc, new_manifest_count, newcrc32; + php_uint32 copy, loc, new_manifest_count; + unsigned int newcrc32; php_stream *file, *newfile, *compressedfile; php_stream_filter *filter; @@ -1531,11 +1532,11 @@ static int phar_flush(php_stream *stream TSRMLS_DC) /* {{{ */ } php_stream_read(entry->temp_file, buffer, copy); php_stream_rewind(entry->temp_file); - newcrc32 = 0; + newcrc32 = ~0; for (loc = 0;loc < copy; loc++) { CRC32(newcrc32, *(buffer + loc)); } - entry->crc32 = newcrc32; + entry->crc32 = ~newcrc32; } } else { if (-1 == php_stream_seek(data->fp, entry->offset_within_phar + data->phar->internal_file_start, SEEK_SET)) { @@ -1574,14 +1575,14 @@ static int phar_flush(php_stream *stream TSRMLS_DC) /* {{{ */ } copy = php_stream_read(data->fp, buffer, entry->uncompressed_filesize); entry->compressed_filesize = copy; - newcrc32 = 0; + newcrc32 = ~0; for (loc = 0;loc < copy; loc++) { CRC32(newcrc32, *(buffer + loc)); } php_stream_filter_remove(filter, 1 TSRMLS_CC); php_stream_rewind(compressedfile); php_stream_write(compressedfile, buffer, copy); - entry->crc32 = newcrc32; + entry->crc32 = ~newcrc32; /* use temp_file to store the newly compressed data */ if (entry->temp_file) { /* no longer need the uncompressed contents */ diff --git a/ext/phar/tests/open_for_write_existing.phpt b/ext/phar/tests/open_for_write_existing.phpt index 769f6e4640..fa94de97df 100644 --- a/ext/phar/tests/open_for_write_existing.phpt +++ b/ext/phar/tests/open_for_write_existing.phpt @@ -28,7 +28,7 @@ file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar. $fp = fopen('phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php', 'wb'); fwrite($fp, 'extra'); fclose($fp); -include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php'; +include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';exit; ?> ===DONE=== --CLEAN--