Lines Matching refs:entry
161 static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */ in phar_tar_process_metadata() argument
167 metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1); in phar_tar_process_metadata()
169 read = php_stream_read(fp, metadata, entry->uncompressed_filesize); in phar_tar_process_metadata()
170 if (read != entry->uncompressed_filesize) { in phar_tar_process_metadata()
176 …if (phar_parse_metadata(&metadata, &entry->metadata, entry->uncompressed_filesize TSRMLS_CC) == FA… in phar_tar_process_metadata()
183 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_process_metadata()
184 entry->phar->metadata = entry->metadata; in phar_tar_process_metadata()
185 entry->metadata = NULL; in phar_tar_process_metadata()
186 …entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && SUCCESS == zen… in phar_tar_process_metadata()
188 mentry->metadata = entry->metadata; in phar_tar_process_metadata()
189 entry->metadata = NULL; in phar_tar_process_metadata()
208 phar_entry_info entry = {0}; in phar_parse_tarfile() local
249 entry.is_tar = 1; in phar_parse_tarfile()
250 entry.is_crc_checked = 1; in phar_parse_tarfile()
251 entry.phar = myphar; in phar_parse_tarfile()
266 size = entry.uncompressed_filesize = entry.compressed_filesize = in phar_parse_tarfile()
356 entry.filename_len = entry.uncompressed_filesize; in phar_parse_tarfile()
359 if (entry.filename_len == UINT_MAX || entry.filename_len == 0) { in phar_parse_tarfile()
367 entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent); in phar_parse_tarfile()
369 read = php_stream_read(fp, entry.filename, entry.filename_len); in phar_parse_tarfile()
370 if (read != entry.filename_len) { in phar_parse_tarfile()
371 efree(entry.filename); in phar_parse_tarfile()
379 entry.filename[entry.filename_len] = '\0'; in phar_parse_tarfile()
387 efree(entry.filename); in phar_parse_tarfile()
399 efree(entry.filename); in phar_parse_tarfile()
426 entry.filename_len = i+j; in phar_parse_tarfile()
428 if (name[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
430 entry.filename_len--; in phar_parse_tarfile()
432 entry.filename = pestrndup(name, entry.filename_len, myphar->is_persistent); in phar_parse_tarfile()
442 entry.filename_len = i; in phar_parse_tarfile()
443 entry.filename = pestrndup(hdr->name, i, myphar->is_persistent); in phar_parse_tarfile()
445 if (i > 0 && entry.filename[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
447 entry.filename[entry.filename_len - 1] = '\0'; in phar_parse_tarfile()
448 entry.filename_len--; in phar_parse_tarfile()
453 phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len TSRMLS_CC); in phar_parse_tarfile()
457 … error: \"%s\" is a corrupted tar file (checksum mismatch of file \"%s\")", fname, entry.filename); in phar_parse_tarfile()
459 pefree(entry.filename, myphar->is_persistent); in phar_parse_tarfile()
465 entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag); in phar_parse_tarfile()
466 entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */ in phar_parse_tarfile()
467 entry.fp_type = PHAR_FP; in phar_parse_tarfile()
468 entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK; in phar_parse_tarfile()
469 entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime)); in phar_parse_tarfile()
470 entry.is_persistent = myphar->is_persistent; in phar_parse_tarfile()
474 if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry.flags)) { in phar_parse_tarfile()
475 entry.tar_type = TAR_DIR; in phar_parse_tarfile()
478 if (entry.tar_type == TAR_DIR) { in phar_parse_tarfile()
479 entry.is_dir = 1; in phar_parse_tarfile()
481 entry.is_dir = 0; in phar_parse_tarfile()
484 entry.link = NULL; in phar_parse_tarfile()
488 if (entry.tar_type == TAR_LINK) { in phar_parse_tarfile()
493 pefree(entry.filename, entry.is_persistent); in phar_parse_tarfile()
498 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
499 } else if (entry.tar_type == TAR_SYMLINK) { in phar_parse_tarfile()
500 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
502 phar_set_inode(&entry TSRMLS_CC); in phar_parse_tarfile()
503 …zend_hash_add(&myphar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_en… in phar_parse_tarfile()
505 if (entry.is_persistent) { in phar_parse_tarfile()
506 ++entry.manifest_pos; in phar_parse_tarfile()
509 …if (entry.filename_len >= sizeof(".phar/.metadata")-1 && !memcmp(entry.filename, ".phar/.metadata"… in phar_parse_tarfile()
512 …ar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"", fname, entry.filename); in phar_parse_tarfile()
520 …if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename,… in phar_parse_tarfile()
702 phar_entry_info *entry = (phar_entry_info *) pDest; in phar_tar_writeheaders() local
706 if (entry->is_mounted) { in phar_tar_writeheaders()
710 if (entry->is_deleted) { in phar_tar_writeheaders()
711 if (entry->fp_refcount <= 0) { in phar_tar_writeheaders()
719 phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len TSRMLS_CC); in phar_tar_writeheaders()
722 if (entry->filename_len > 100) { in phar_tar_writeheaders()
724 if (entry->filename_len > 256) { in phar_tar_writeheaders()
726 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
730 boundary = entry->filename + entry->filename_len - 101; in phar_tar_writeheaders()
734 if (!*boundary || ((boundary - entry->filename) > 155)) { in phar_tar_writeheaders()
736 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
740 memcpy(header.prefix, entry->filename, boundary - entry->filename); in phar_tar_writeheaders()
741 memcpy(header.name, boundary + 1, entry->filename_len - (boundary + 1 - entry->filename)); in phar_tar_writeheaders()
743 memcpy(header.name, entry->filename, entry->filename_len); in phar_tar_writeheaders()
746 phar_tar_octal(header.mode, entry->flags & PHAR_ENT_PERM_MASK, sizeof(header.mode)-1); in phar_tar_writeheaders()
748 if (FAILURE == phar_tar_octal(header.size, entry->uncompressed_filesize, sizeof(header.size)-1)) { in phar_tar_writeheaders()
750 … be created, filename \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
755 if (FAILURE == phar_tar_octal(header.mtime, entry->timestamp, sizeof(header.mtime)-1)) { in phar_tar_writeheaders()
757 …fication time of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
763 header.typeflag = entry->tar_type; in phar_tar_writeheaders()
765 if (entry->link) { in phar_tar_writeheaders()
766 strncpy(header.linkname, entry->link, strlen(entry->link)); in phar_tar_writeheaders()
772 entry->crc32 = phar_tar_checksum((char *)&header, sizeof(header)); in phar_tar_writeheaders()
774 if (FAILURE == phar_tar_octal(header.checksum, entry->crc32, sizeof(header.checksum)-1)) { in phar_tar_writeheaders()
776 …ted, checksum of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
782 entry->header_offset = php_stream_tell(fp->new); in phar_tar_writeheaders()
786 …nnot be created, header for file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
794 if (entry->uncompressed_filesize) { in phar_tar_writeheaders()
795 if (FAILURE == phar_open_entry_fp(entry, fp->error, 0 TSRMLS_CC)) { in phar_tar_writeheaders()
799 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) { in phar_tar_writeheaders()
801 …ed, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
806 …if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), fp->new, entry->uncomp… in phar_tar_writeheaders()
808 …nnot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
814 …php_stream_write(fp->new, padding, ((entry->uncompressed_filesize +511)&~511) - entry->uncompresse… in phar_tar_writeheaders()
817 if (!entry->is_modified && entry->fp_refcount) { in phar_tar_writeheaders()
819 switch (entry->fp_type) { in phar_tar_writeheaders()
830 entry->is_modified = 0; in phar_tar_writeheaders()
832 if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) { in phar_tar_writeheaders()
833 if (!entry->fp_refcount) { in phar_tar_writeheaders()
834 php_stream_close(entry->fp); in phar_tar_writeheaders()
836 entry->fp = NULL; in phar_tar_writeheaders()
839 entry->fp_type = PHAR_FP; in phar_tar_writeheaders()
842 entry->offset = entry->offset_abs = pos; in phar_tar_writeheaders()
847 int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */ in phar_tar_setmetadata() argument
851 if (entry->metadata_str.c) { in phar_tar_setmetadata()
852 smart_str_free(&entry->metadata_str); in phar_tar_setmetadata()
855 entry->metadata_str.c = 0; in phar_tar_setmetadata()
856 entry->metadata_str.len = 0; in phar_tar_setmetadata()
858 php_var_serialize(&entry->metadata_str, &metadata, &metadata_hash TSRMLS_CC); in phar_tar_setmetadata()
860 entry->uncompressed_filesize = entry->compressed_filesize = entry->metadata_str.len; in phar_tar_setmetadata()
862 if (entry->fp && entry->fp_type == PHAR_MOD) { in phar_tar_setmetadata()
863 php_stream_close(entry->fp); in phar_tar_setmetadata()
866 entry->fp_type = PHAR_MOD; in phar_tar_setmetadata()
867 entry->is_modified = 1; in phar_tar_setmetadata()
868 entry->fp = php_stream_fopen_tmpfile(); in phar_tar_setmetadata()
869 entry->offset = entry->offset_abs = 0; in phar_tar_setmetadata()
870 if (entry->fp == NULL) { in phar_tar_setmetadata()
874 …if (entry->metadata_str.len != php_stream_write(entry->fp, entry->metadata_str.c, entry->metadata_… in phar_tar_setmetadata()
875 …ror, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename); in phar_tar_setmetadata()
876 zend_hash_del(&(entry->phar->manifest), entry->filename, entry->filename_len); in phar_tar_setmetadata()
889 phar_entry_info *entry = (phar_entry_info *)pDest, *metadata, newentry = {0}; in phar_tar_setupmetadata() local
891 …if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata"… in phar_tar_setupmetadata()
892 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_setupmetadata()
893 if (entry->phar->metadata == NULL) { in phar_tar_setupmetadata()
896 return phar_tar_setmetadata(entry->phar->metadata, entry, error TSRMLS_CC); in phar_tar_setupmetadata()
899 …entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_exi… in phar_tar_setupmetadata()
907 if (!entry->is_modified) { in phar_tar_setupmetadata()
912 lookfor_len = spprintf(&lookfor, 0, ".phar/.metadata/%s/.metadata.bin", entry->filename); in phar_tar_setupmetadata()
914 if (!entry->metadata) { in phar_tar_setupmetadata()
915 zend_hash_del(&(entry->phar->manifest), lookfor, lookfor_len); in phar_tar_setupmetadata()
920 …if (SUCCESS == zend_hash_find(&(entry->phar->manifest), lookfor, lookfor_len, (void **)&metadata))… in phar_tar_setupmetadata()
922 ret = phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC); in phar_tar_setupmetadata()
929 newentry.phar = entry->phar; in phar_tar_setupmetadata()
933 …if (SUCCESS != zend_hash_add(&(entry->phar->manifest), lookfor, lookfor_len, (void *)&newentry, si… in phar_tar_setupmetadata()
935 … "phar tar error: unable to add magic metadata file to manifest for file \"%s\"", entry->filename); in phar_tar_setupmetadata()
939 return phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC); in phar_tar_setupmetadata()
945 phar_entry_info entry = {0}; in phar_tar_flush() local
953 entry.flags = PHAR_ENT_PERM_DEF_FILE; in phar_tar_flush()
954 entry.timestamp = time(NULL); in phar_tar_flush()
955 entry.is_modified = 1; in phar_tar_flush()
956 entry.is_crc_checked = 1; in phar_tar_flush()
957 entry.is_tar = 1; in phar_tar_flush()
958 entry.tar_type = '0'; in phar_tar_flush()
959 entry.phar = phar; in phar_tar_flush()
960 entry.fp_type = PHAR_MOD; in phar_tar_flush()
975 entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1); in phar_tar_flush()
976 entry.filename_len = sizeof(".phar/alias.txt")-1; in phar_tar_flush()
977 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
978 if (entry.fp == NULL) { in phar_tar_flush()
982 if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) { in phar_tar_flush()
989 entry.uncompressed_filesize = phar->alias_len; in phar_tar_flush()
991 …if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry… in phar_tar_flush()
1045 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1046 if (entry.fp == NULL) { in phar_tar_flush()
1050 entry.uncompressed_filesize = len + 5; in phar_tar_flush()
1052 if ((size_t)len != php_stream_write(entry.fp, user_stub, len) in phar_tar_flush()
1053 || 5 != php_stream_write(entry.fp, " ?>\r\n", 5)) { in phar_tar_flush()
1060 php_stream_close(entry.fp); in phar_tar_flush()
1064 entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); in phar_tar_flush()
1065 entry.filename_len = sizeof(".phar/stub.php")-1; in phar_tar_flush()
1066 …zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_e… in phar_tar_flush()
1073 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1074 if (entry.fp == NULL) { in phar_tar_flush()
1078 if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { in phar_tar_flush()
1079 php_stream_close(entry.fp); in phar_tar_flush()
1086 entry.uncompressed_filesize = entry.compressed_filesize = sizeof(newstub) - 1; in phar_tar_flush()
1087 entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); in phar_tar_flush()
1088 entry.filename_len = sizeof(".phar/stub.php")-1; in phar_tar_flush()
1092 …if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, s… in phar_tar_flush()
1093 php_stream_close(entry.fp); in phar_tar_flush()
1094 efree(entry.filename); in phar_tar_flush()
1101 php_stream_close(entry.fp); in phar_tar_flush()
1102 efree(entry.filename); in phar_tar_flush()
1105 …if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry… in phar_tar_flush()
1106 php_stream_close(entry.fp); in phar_tar_flush()
1107 efree(entry.filename); in phar_tar_flush()
1209 entry.filename = ".phar/signature.bin"; in phar_tar_flush()
1210 entry.filename_len = sizeof(".phar/signature.bin")-1; in phar_tar_flush()
1211 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1212 if (entry.fp == NULL) { in phar_tar_flush()
1228 …if (8 != (int)php_stream_write(entry.fp, sigbuf, 8) || signature_length != (int)php_stream_write(e… in phar_tar_flush()
1242 entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8; in phar_tar_flush()
1244 entry.filename_len = phar_tar_writeheaders((void *)&entry, (void *)&pass TSRMLS_CC); in phar_tar_flush()