]> granicus.if.org Git - php/commitdiff
- Fix issues found with solaris
authorMarcus Boerger <helly@php.net>
Tue, 6 Feb 2007 23:19:10 +0000 (23:19 +0000)
committerMarcus Boerger <helly@php.net>
Tue, 6 Feb 2007 23:19:10 +0000 (23:19 +0000)
ext/phar/phar.c

index 2a053f4822d1b0baa6837ca2b2d1b636fc0b40cf..018e6b562fbfccb4a5ca7b864d3b94926d541e1a 100644 (file)
@@ -596,6 +596,8 @@ static int phar_parse_metadata(php_stream *fp, char **buffer, char *endbuffer, z
                        return FAILURE;
                }
                PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
+       } else {
+               *metadata = NULL;
        }
        *buffer += buf_len;
        return SUCCESS;
@@ -869,13 +871,10 @@ int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alias, int
        }
 
        mydata = ecalloc(sizeof(phar_archive_data), 1);
-       if (*(php_uint32 *) buffer) {
-               if (phar_parse_metadata(fp, &buffer, endbuffer, &mydata->metadata TSRMLS_CC) == FAILURE) {
-                       MAPPHAR_FAIL("unable to read phar metadata in .phar file \"%s\"");
-               }
-       } else {
-               mydata->metadata = 0;
-               buffer += 4;
+
+       /* check whetehr we have meta data, zero check works regardless of byte order */
+       if (phar_parse_metadata(fp, &buffer, endbuffer, &mydata->metadata TSRMLS_CC) == FAILURE) {
+               MAPPHAR_FAIL("unable to read phar metadata in .phar file \"%s\"");
        }
        
        /* set up our manifest */
@@ -911,13 +910,9 @@ int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alias, int
                PHAR_GET_32(buffer, entry.compressed_filesize);
                PHAR_GET_32(buffer, entry.crc32);
                PHAR_GET_32(buffer, entry.flags);
-               if (*(php_uint32 *) buffer) {
-                       if (phar_parse_metadata(fp, &buffer, endbuffer, &entry.metadata TSRMLS_CC) == FAILURE) {
-                               efree(entry.filename);
-                               MAPPHAR_FAIL("unable to read file metadata in .phar file \"%s\"");
-                       }
-               } else {
-                       buffer += 4;
+               if (phar_parse_metadata(fp, &buffer, endbuffer, &entry.metadata TSRMLS_CC) == FAILURE) {
+                       efree(entry.filename);
+                       MAPPHAR_FAIL("unable to read file metadata in .phar file \"%s\"");
                }
                entry.offset_within_phar = offset;
                offset += entry.compressed_filesize;