Lines Matching refs:entry

158 static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */  in phar_tar_process_metadata()  argument
164 metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1); in phar_tar_process_metadata()
166 read = php_stream_read(fp, metadata, entry->uncompressed_filesize); in phar_tar_process_metadata()
167 if (read != entry->uncompressed_filesize) { in phar_tar_process_metadata()
173 …if (phar_parse_metadata(&metadata, &entry->metadata, entry->uncompressed_filesize TSRMLS_CC) == FA… in phar_tar_process_metadata()
180 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_process_metadata()
181 entry->phar->metadata = entry->metadata; in phar_tar_process_metadata()
182 entry->metadata = NULL; in phar_tar_process_metadata()
183entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && SUCCESS == zen… in phar_tar_process_metadata()
185 mentry->metadata = entry->metadata; in phar_tar_process_metadata()
186 entry->metadata = NULL; in phar_tar_process_metadata()
198 phar_entry_info entry = {0}; in phar_parse_tarfile() local
238 entry.is_tar = 1; in phar_parse_tarfile()
239 entry.is_crc_checked = 1; in phar_parse_tarfile()
240 entry.phar = myphar; in phar_parse_tarfile()
255 size = entry.uncompressed_filesize = entry.compressed_filesize = in phar_parse_tarfile()
339 entry.filename_len = entry.uncompressed_filesize; in phar_parse_tarfile()
342 if (entry.filename_len == UINT_MAX) { in phar_parse_tarfile()
350 entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent); in phar_parse_tarfile()
352 read = php_stream_read(fp, entry.filename, entry.filename_len); in phar_parse_tarfile()
353 if (read != entry.filename_len) { in phar_parse_tarfile()
354 efree(entry.filename); in phar_parse_tarfile()
362 entry.filename[entry.filename_len] = '\0'; in phar_parse_tarfile()
370 efree(entry.filename); in phar_parse_tarfile()
382 efree(entry.filename); in phar_parse_tarfile()
409 entry.filename_len = i+j; in phar_parse_tarfile()
411 if (name[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
413 entry.filename_len--; in phar_parse_tarfile()
415 entry.filename = pestrndup(name, entry.filename_len, myphar->is_persistent); in phar_parse_tarfile()
425 entry.filename_len = i; in phar_parse_tarfile()
426 entry.filename = pestrndup(hdr->name, i, myphar->is_persistent); in phar_parse_tarfile()
428 if (i > 0 && entry.filename[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
430 entry.filename[entry.filename_len - 1] = '\0'; in phar_parse_tarfile()
431 entry.filename_len--; in phar_parse_tarfile()
436 phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len TSRMLS_CC); in phar_parse_tarfile()
440 … error: \"%s\" is a corrupted tar file (checksum mismatch of file \"%s\")", fname, entry.filename); in phar_parse_tarfile()
442 pefree(entry.filename, myphar->is_persistent); in phar_parse_tarfile()
448 entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag); in phar_parse_tarfile()
449 entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */ in phar_parse_tarfile()
450 entry.fp_type = PHAR_FP; in phar_parse_tarfile()
451 entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK; in phar_parse_tarfile()
452 entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime)); in phar_parse_tarfile()
453 entry.is_persistent = myphar->is_persistent; in phar_parse_tarfile()
457 if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry.flags)) { in phar_parse_tarfile()
458 entry.tar_type = TAR_DIR; in phar_parse_tarfile()
461 if (entry.tar_type == TAR_DIR) { in phar_parse_tarfile()
462 entry.is_dir = 1; in phar_parse_tarfile()
464 entry.is_dir = 0; in phar_parse_tarfile()
467 entry.link = NULL; in phar_parse_tarfile()
469 if (entry.tar_type == TAR_LINK) { in phar_parse_tarfile()
474 pefree(entry.filename, entry.is_persistent); in phar_parse_tarfile()
479 entry.link = estrdup(hdr->linkname); in phar_parse_tarfile()
480 } else if (entry.tar_type == TAR_SYMLINK) { in phar_parse_tarfile()
481 entry.link = estrdup(hdr->linkname); in phar_parse_tarfile()
483 phar_set_inode(&entry TSRMLS_CC); in phar_parse_tarfile()
484 …zend_hash_add(&myphar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_en… in phar_parse_tarfile()
486 if (entry.is_persistent) { in phar_parse_tarfile()
487 ++entry.manifest_pos; in phar_parse_tarfile()
490 …if (entry.filename_len >= sizeof(".phar/.metadata")-1 && !memcmp(entry.filename, ".phar/.metadata"… in phar_parse_tarfile()
493 …ar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"", fname, entry.filename); in phar_parse_tarfile()
501 …if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename,… in phar_parse_tarfile()
682 phar_entry_info *entry = (phar_entry_info *) pDest; in phar_tar_writeheaders() local
686 if (entry->is_mounted) { in phar_tar_writeheaders()
690 if (entry->is_deleted) { in phar_tar_writeheaders()
691 if (entry->fp_refcount <= 0) { in phar_tar_writeheaders()
699 phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len TSRMLS_CC); in phar_tar_writeheaders()
702 if (entry->filename_len > 100) { in phar_tar_writeheaders()
704 if (entry->filename_len > 256) { in phar_tar_writeheaders()
706 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
710 boundary = entry->filename + entry->filename_len - 101; in phar_tar_writeheaders()
714 if (!*boundary || ((boundary - entry->filename) > 155)) { in phar_tar_writeheaders()
716 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
720 memcpy(header.prefix, entry->filename, boundary - entry->filename); in phar_tar_writeheaders()
721 memcpy(header.name, boundary + 1, entry->filename_len - (boundary + 1 - entry->filename)); in phar_tar_writeheaders()
723 memcpy(header.name, entry->filename, entry->filename_len); in phar_tar_writeheaders()
726 phar_tar_octal(header.mode, entry->flags & PHAR_ENT_PERM_MASK, sizeof(header.mode)-1); in phar_tar_writeheaders()
728 if (FAILURE == phar_tar_octal(header.size, entry->uncompressed_filesize, sizeof(header.size)-1)) { in phar_tar_writeheaders()
730 … be created, filename \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
735 if (FAILURE == phar_tar_octal(header.mtime, entry->timestamp, sizeof(header.mtime)-1)) { in phar_tar_writeheaders()
737 …fication time of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
743 header.typeflag = entry->tar_type; in phar_tar_writeheaders()
745 if (entry->link) { in phar_tar_writeheaders()
746 strncpy(header.linkname, entry->link, strlen(entry->link)); in phar_tar_writeheaders()
752 entry->crc32 = phar_tar_checksum((char *)&header, sizeof(header)); in phar_tar_writeheaders()
754 if (FAILURE == phar_tar_octal(header.checksum, entry->crc32, sizeof(header.checksum)-1)) { in phar_tar_writeheaders()
756 …ted, checksum of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
762 entry->header_offset = php_stream_tell(fp->new); in phar_tar_writeheaders()
766 …nnot be created, header for file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
774 if (entry->uncompressed_filesize) { in phar_tar_writeheaders()
775 if (FAILURE == phar_open_entry_fp(entry, fp->error, 0 TSRMLS_CC)) { in phar_tar_writeheaders()
779 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0 TSRMLS_CC)) { in phar_tar_writeheaders()
781 …ed, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
786 …if (SUCCESS != phar_stream_copy_to_stream(phar_get_efp(entry, 0 TSRMLS_CC), fp->new, entry->uncomp… in phar_tar_writeheaders()
788 …nnot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders()
794 …php_stream_write(fp->new, padding, ((entry->uncompressed_filesize +511)&~511) - entry->uncompresse… in phar_tar_writeheaders()
797 if (!entry->is_modified && entry->fp_refcount) { in phar_tar_writeheaders()
799 switch (entry->fp_type) { in phar_tar_writeheaders()
810 entry->is_modified = 0; in phar_tar_writeheaders()
812 if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) { in phar_tar_writeheaders()
813 if (!entry->fp_refcount) { in phar_tar_writeheaders()
814 php_stream_close(entry->fp); in phar_tar_writeheaders()
816 entry->fp = NULL; in phar_tar_writeheaders()
819 entry->fp_type = PHAR_FP; in phar_tar_writeheaders()
822 entry->offset = entry->offset_abs = pos; in phar_tar_writeheaders()
827 int phar_tar_setmetadata(zval *metadata, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */ in phar_tar_setmetadata() argument
831 if (entry->metadata_str.c) { in phar_tar_setmetadata()
832 smart_str_free(&entry->metadata_str); in phar_tar_setmetadata()
835 entry->metadata_str.c = 0; in phar_tar_setmetadata()
836 entry->metadata_str.len = 0; in phar_tar_setmetadata()
838 php_var_serialize(&entry->metadata_str, &metadata, &metadata_hash TSRMLS_CC); in phar_tar_setmetadata()
840 entry->uncompressed_filesize = entry->compressed_filesize = entry->metadata_str.len; in phar_tar_setmetadata()
842 if (entry->fp && entry->fp_type == PHAR_MOD) { in phar_tar_setmetadata()
843 php_stream_close(entry->fp); in phar_tar_setmetadata()
846 entry->fp_type = PHAR_MOD; in phar_tar_setmetadata()
847 entry->is_modified = 1; in phar_tar_setmetadata()
848 entry->fp = php_stream_fopen_tmpfile(); in phar_tar_setmetadata()
849 entry->offset = entry->offset_abs = 0; in phar_tar_setmetadata()
850 if (entry->fp == NULL) { in phar_tar_setmetadata()
854 …if (entry->metadata_str.len != php_stream_write(entry->fp, entry->metadata_str.c, entry->metadata_… in phar_tar_setmetadata()
855 …ror, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename); in phar_tar_setmetadata()
856 zend_hash_del(&(entry->phar->manifest), entry->filename, entry->filename_len); in phar_tar_setmetadata()
869 phar_entry_info *entry = (phar_entry_info *)pDest, *metadata, newentry = {0}; in phar_tar_setupmetadata() local
871 …if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata"… in phar_tar_setupmetadata()
872 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_setupmetadata()
873 return phar_tar_setmetadata(entry->phar->metadata, entry, error TSRMLS_CC); in phar_tar_setupmetadata()
876entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_exi… in phar_tar_setupmetadata()
884 if (!entry->is_modified) { in phar_tar_setupmetadata()
889 lookfor_len = spprintf(&lookfor, 0, ".phar/.metadata/%s/.metadata.bin", entry->filename); in phar_tar_setupmetadata()
891 if (!entry->metadata) { in phar_tar_setupmetadata()
892 zend_hash_del(&(entry->phar->manifest), lookfor, lookfor_len); in phar_tar_setupmetadata()
897 …if (SUCCESS == zend_hash_find(&(entry->phar->manifest), lookfor, lookfor_len, (void **)&metadata))… in phar_tar_setupmetadata()
899 ret = phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC); in phar_tar_setupmetadata()
906 newentry.phar = entry->phar; in phar_tar_setupmetadata()
910 …if (SUCCESS != zend_hash_add(&(entry->phar->manifest), lookfor, lookfor_len, (void *)&newentry, si… in phar_tar_setupmetadata()
912 … "phar tar error: unable to add magic metadata file to manifest for file \"%s\"", entry->filename); in phar_tar_setupmetadata()
916 return phar_tar_setmetadata(entry->metadata, metadata, error TSRMLS_CC); in phar_tar_setupmetadata()
922 phar_entry_info entry = {0}; in phar_tar_flush() local
930 entry.flags = PHAR_ENT_PERM_DEF_FILE; in phar_tar_flush()
931 entry.timestamp = time(NULL); in phar_tar_flush()
932 entry.is_modified = 1; in phar_tar_flush()
933 entry.is_crc_checked = 1; in phar_tar_flush()
934 entry.is_tar = 1; in phar_tar_flush()
935 entry.tar_type = '0'; in phar_tar_flush()
936 entry.phar = phar; in phar_tar_flush()
937 entry.fp_type = PHAR_MOD; in phar_tar_flush()
952 entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1); in phar_tar_flush()
953 entry.filename_len = sizeof(".phar/alias.txt")-1; in phar_tar_flush()
954 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
955 if (entry.fp == NULL) { in phar_tar_flush()
959 if (phar->alias_len != (int)php_stream_write(entry.fp, phar->alias, phar->alias_len)) { in phar_tar_flush()
966 entry.uncompressed_filesize = phar->alias_len; in phar_tar_flush()
968 …if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry in phar_tar_flush()
1022 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1023 if (entry.fp == NULL) { in phar_tar_flush()
1027 entry.uncompressed_filesize = len + 5; in phar_tar_flush()
1029 if ((size_t)len != php_stream_write(entry.fp, user_stub, len) in phar_tar_flush()
1030 || 5 != php_stream_write(entry.fp, " ?>\r\n", 5)) { in phar_tar_flush()
1037 php_stream_close(entry.fp); in phar_tar_flush()
1041 entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); in phar_tar_flush()
1042 entry.filename_len = sizeof(".phar/stub.php")-1; in phar_tar_flush()
1043 …zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeof(phar_e… in phar_tar_flush()
1050 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1051 if (entry.fp == NULL) { in phar_tar_flush()
1055 if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { in phar_tar_flush()
1056 php_stream_close(entry.fp); in phar_tar_flush()
1063 entry.uncompressed_filesize = entry.compressed_filesize = sizeof(newstub) - 1; 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()
1069 …if (SUCCESS != zend_hash_add(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, s… in phar_tar_flush()
1070 php_stream_close(entry.fp); in phar_tar_flush()
1071 efree(entry.filename); in phar_tar_flush()
1078 php_stream_close(entry.fp); in phar_tar_flush()
1079 efree(entry.filename); in phar_tar_flush()
1082 …if (SUCCESS != zend_hash_update(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry in phar_tar_flush()
1083 php_stream_close(entry.fp); in phar_tar_flush()
1084 efree(entry.filename); in phar_tar_flush()
1186 entry.filename = ".phar/signature.bin"; in phar_tar_flush()
1187 entry.filename_len = sizeof(".phar/signature.bin")-1; in phar_tar_flush()
1188 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1189 if (entry.fp == NULL) { in phar_tar_flush()
1205 …if (8 != (int)php_stream_write(entry.fp, sigbuf, 8) || signature_length != (int)php_stream_write(e… in phar_tar_flush()
1219 entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8; in phar_tar_flush()
1221 entry.filename_len = phar_tar_writeheaders((void *)&entry, (void *)&pass TSRMLS_CC); in phar_tar_flush()