Lines Matching refs:entry

161 static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp) /* {{{ */  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 …phar_parse_metadata_lazy(metadata, &entry->metadata_tracker, entry->uncompressed_filesize, entry->… in phar_tar_process_metadata()
178 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_process_metadata()
179 if (phar_metadata_tracker_has_data(&entry->phar->metadata_tracker, entry->phar->is_persistent)) { in phar_tar_process_metadata()
183 entry->phar->metadata_tracker = entry->metadata_tracker; in phar_tar_process_metadata()
184 entry->metadata_tracker.str = NULL; in phar_tar_process_metadata()
185 ZVAL_UNDEF(&entry->metadata_tracker.val); in phar_tar_process_metadata()
186entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && NULL != (mentr… in phar_tar_process_metadata()
192 mentry->metadata_tracker = entry->metadata_tracker; in phar_tar_process_metadata()
193 entry->metadata_tracker.str = NULL; in phar_tar_process_metadata()
194 ZVAL_UNDEF(&entry->metadata_tracker.val); in phar_tar_process_metadata()
213 phar_entry_info entry = {0}; in phar_parse_tarfile() local
254 entry.is_tar = 1; in phar_parse_tarfile()
255 entry.is_crc_checked = 1; in phar_parse_tarfile()
256 entry.phar = myphar; in phar_parse_tarfile()
280 size = entry.uncompressed_filesize = entry.compressed_filesize = in phar_parse_tarfile()
372 entry.filename_len = entry.uncompressed_filesize; in phar_parse_tarfile()
375 if (entry.filename_len == UINT_MAX || entry.filename_len == 0) { in phar_parse_tarfile()
383 entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent); in phar_parse_tarfile()
385 read = php_stream_read(fp, entry.filename, entry.filename_len); in phar_parse_tarfile()
386 if (read != entry.filename_len) { in phar_parse_tarfile()
387 efree(entry.filename); in phar_parse_tarfile()
395 entry.filename[entry.filename_len] = '\0'; in phar_parse_tarfile()
403 efree(entry.filename); in phar_parse_tarfile()
415 efree(entry.filename); in phar_parse_tarfile()
442 entry.filename_len = i+j; in phar_parse_tarfile()
444 if (name[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
446 entry.filename_len--; in phar_parse_tarfile()
448 entry.filename = pestrndup(name, entry.filename_len, myphar->is_persistent); in phar_parse_tarfile()
458 entry.filename_len = i; in phar_parse_tarfile()
459 entry.filename = pestrndup(hdr->name, i, myphar->is_persistent); in phar_parse_tarfile()
461 if (i > 0 && entry.filename[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
463 entry.filename[entry.filename_len - 1] = '\0'; in phar_parse_tarfile()
464 entry.filename_len--; in phar_parse_tarfile()
469 phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len); in phar_parse_tarfile()
473 … error: \"%s\" is a corrupted tar file (checksum mismatch of file \"%s\")", fname, entry.filename); in phar_parse_tarfile()
475 pefree(entry.filename, myphar->is_persistent); in phar_parse_tarfile()
482 entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag); in phar_parse_tarfile()
483 entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */ in phar_parse_tarfile()
484 entry.fp_type = PHAR_FP; in phar_parse_tarfile()
485 entry.flags = entry_mode & PHAR_ENT_PERM_MASK; in phar_parse_tarfile()
486 entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime)); in phar_parse_tarfile()
487 entry.is_persistent = myphar->is_persistent; in phar_parse_tarfile()
489 if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry_mode)) { in phar_parse_tarfile()
490 entry.tar_type = TAR_DIR; in phar_parse_tarfile()
493 if (entry.tar_type == TAR_DIR) { in phar_parse_tarfile()
494 entry.is_dir = 1; in phar_parse_tarfile()
496 entry.is_dir = 0; in phar_parse_tarfile()
499 entry.link = NULL; in phar_parse_tarfile()
503 if (entry.tar_type == TAR_LINK) { in phar_parse_tarfile()
508 pefree(entry.filename, entry.is_persistent); in phar_parse_tarfile()
513 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
514 } else if (entry.tar_type == TAR_SYMLINK) { in phar_parse_tarfile()
515 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
517 phar_set_inode(&entry); in phar_parse_tarfile()
519 …entry = zend_hash_str_update_mem(&myphar->manifest, entry.filename, entry.filename_len, (void*)&en… in phar_parse_tarfile()
522 if (entry.is_persistent) { in phar_parse_tarfile()
523 ++entry.manifest_pos; in phar_parse_tarfile()
526 …if (entry.filename_len >= sizeof(".phar/.metadata")-1 && !memcmp(entry.filename, ".phar/.metadata"… in phar_parse_tarfile()
529 …ar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"", fname, entry.filename); in phar_parse_tarfile()
537 …if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename,… in phar_parse_tarfile()
715 static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* {{{ */ in phar_tar_writeheaders_int() argument
722 if (entry->is_mounted) { in phar_tar_writeheaders_int()
726 if (entry->is_deleted) { in phar_tar_writeheaders_int()
727 if (entry->fp_refcount <= 0) { in phar_tar_writeheaders_int()
735 phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len); in phar_tar_writeheaders_int()
738 if (entry->filename_len > 100) { in phar_tar_writeheaders_int()
740 if (entry->filename_len > 256) { in phar_tar_writeheaders_int()
742 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
746 boundary = entry->filename + entry->filename_len - 101; in phar_tar_writeheaders_int()
750 if (!*boundary || ((boundary - entry->filename) > 155)) { in phar_tar_writeheaders_int()
752 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
756 memcpy(header.prefix, entry->filename, boundary - entry->filename); in phar_tar_writeheaders_int()
757 memcpy(header.name, boundary + 1, entry->filename_len - (boundary + 1 - entry->filename)); in phar_tar_writeheaders_int()
759 memcpy(header.name, entry->filename, entry->filename_len); in phar_tar_writeheaders_int()
762 phar_tar_octal(header.mode, entry->flags & PHAR_ENT_PERM_MASK, sizeof(header.mode)-1); in phar_tar_writeheaders_int()
764 if (FAILURE == phar_tar_octal(header.size, entry->uncompressed_filesize, sizeof(header.size)-1)) { in phar_tar_writeheaders_int()
766 … be created, filename \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
771 if (FAILURE == phar_tar_octal(header.mtime, entry->timestamp, sizeof(header.mtime)-1)) { in phar_tar_writeheaders_int()
773 …fication time of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
779 header.typeflag = entry->tar_type; in phar_tar_writeheaders_int()
781 if (entry->link) { in phar_tar_writeheaders_int()
782 if (strlcpy(header.linkname, entry->link, sizeof(header.linkname)) >= sizeof(header.linkname)) { in phar_tar_writeheaders_int()
784 …ar \"%s\" cannot be created, link \"%s\" is too long for format", entry->phar->fname, entry->link); in phar_tar_writeheaders_int()
793 entry->crc32 = phar_tar_checksum((char *)&header, sizeof(header)); in phar_tar_writeheaders_int()
795 if (FAILURE == phar_tar_octal(header.checksum, entry->crc32, sizeof(header.checksum)-1)) { in phar_tar_writeheaders_int()
797 …ted, checksum of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
803 entry->header_offset = php_stream_tell(fp->new); in phar_tar_writeheaders_int()
807 …nnot be created, header for file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
815 if (entry->uncompressed_filesize) { in phar_tar_writeheaders_int()
816 if (FAILURE == phar_open_entry_fp(entry, fp->error, 0)) { in phar_tar_writeheaders_int()
820 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { in phar_tar_writeheaders_int()
822 …ed, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
827 …if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp->new, entry->uncompressed_f… in phar_tar_writeheaders_int()
829 …nnot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
835 …php_stream_write(fp->new, padding, ((entry->uncompressed_filesize +511)&~511) - entry->uncompresse… in phar_tar_writeheaders_int()
838 if (!entry->is_modified && entry->fp_refcount) { in phar_tar_writeheaders_int()
840 switch (entry->fp_type) { in phar_tar_writeheaders_int()
851 entry->is_modified = 0; in phar_tar_writeheaders_int()
853 if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) { in phar_tar_writeheaders_int()
854 if (!entry->fp_refcount) { in phar_tar_writeheaders_int()
855 php_stream_close(entry->fp); in phar_tar_writeheaders_int()
857 entry->fp = NULL; in phar_tar_writeheaders_int()
860 entry->fp_type = PHAR_FP; in phar_tar_writeheaders_int()
863 entry->offset = entry->offset_abs = pos; in phar_tar_writeheaders_int()
874 int phar_tar_setmetadata(const phar_metadata_tracker *tracker, phar_entry_info *entry, char **error… in phar_tar_setmetadata() argument
878 phar_metadata_tracker_copy(&entry->metadata_tracker, tracker, entry->is_persistent); in phar_tar_setmetadata()
879 …phar_metadata_tracker_try_ensure_has_serialized_data(&entry->metadata_tracker, entry->is_persisten… in phar_tar_setmetadata()
880 serialized_str = entry->metadata_tracker.str; in phar_tar_setmetadata()
883entry->uncompressed_filesize = entry->compressed_filesize = serialized_str ? ZSTR_LEN(serialized_s… in phar_tar_setmetadata()
885 if (entry->fp && entry->fp_type == PHAR_MOD) { in phar_tar_setmetadata()
886 php_stream_close(entry->fp); in phar_tar_setmetadata()
889 entry->fp_type = PHAR_MOD; in phar_tar_setmetadata()
890 entry->is_modified = 1; in phar_tar_setmetadata()
891 entry->fp = php_stream_fopen_tmpfile(); in phar_tar_setmetadata()
892 entry->offset = entry->offset_abs = 0; in phar_tar_setmetadata()
893 if (entry->fp == NULL) { in phar_tar_setmetadata()
897 …if (serialized_str && ZSTR_LEN(serialized_str) != php_stream_write(entry->fp, ZSTR_VAL(serialized_… in phar_tar_setmetadata()
898 …ror, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename); in phar_tar_setmetadata()
899 zend_hash_str_del(&(entry->phar->manifest), entry->filename, entry->filename_len); in phar_tar_setmetadata()
912 phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv), *metadata, newentry = {0}; in phar_tar_setupmetadata() local
914 …if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata"… in phar_tar_setupmetadata()
915 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_setupmetadata()
916 return phar_tar_setmetadata(&entry->phar->metadata_tracker, entry, error); in phar_tar_setupmetadata()
919entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_str… in phar_tar_setupmetadata()
927 if (!entry->is_modified) { in phar_tar_setupmetadata()
932 lookfor_len = spprintf(&lookfor, 0, ".phar/.metadata/%s/.metadata.bin", entry->filename); in phar_tar_setupmetadata()
934 if (!phar_metadata_tracker_has_data(&entry->metadata_tracker, entry->is_persistent)) { in phar_tar_setupmetadata()
935 zend_hash_str_del(&(entry->phar->manifest), lookfor, lookfor_len); in phar_tar_setupmetadata()
940 if (NULL != (metadata = zend_hash_str_find_ptr(&(entry->phar->manifest), lookfor, lookfor_len))) { in phar_tar_setupmetadata()
942 ret = phar_tar_setmetadata(&entry->metadata_tracker, metadata, error); in phar_tar_setupmetadata()
949 newentry.phar = entry->phar; in phar_tar_setupmetadata()
953 …if (NULL == (metadata = zend_hash_str_add_mem(&(entry->phar->manifest), lookfor, lookfor_len, (voi… in phar_tar_setupmetadata()
955 … "phar tar error: unable to add magic metadata file to manifest for file \"%s\"", entry->filename); in phar_tar_setupmetadata()
959 return phar_tar_setmetadata(&entry->metadata_tracker, metadata, error); in phar_tar_setupmetadata()
965 phar_entry_info entry = {0}; in phar_tar_flush() local
974 entry.flags = PHAR_ENT_PERM_DEF_FILE; in phar_tar_flush()
975 entry.timestamp = time(NULL); in phar_tar_flush()
976 entry.is_modified = 1; in phar_tar_flush()
977 entry.is_crc_checked = 1; in phar_tar_flush()
978 entry.is_tar = 1; in phar_tar_flush()
979 entry.tar_type = '0'; in phar_tar_flush()
980 entry.phar = phar; in phar_tar_flush()
981 entry.fp_type = PHAR_MOD; in phar_tar_flush()
982 entry.fp = NULL; in phar_tar_flush()
983 entry.filename = NULL; in phar_tar_flush()
998 entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1); in phar_tar_flush()
999 entry.filename_len = sizeof(".phar/alias.txt")-1; in phar_tar_flush()
1000 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1001 if (entry.fp == NULL) { in phar_tar_flush()
1002 efree(entry.filename); in phar_tar_flush()
1006 if (phar->alias_len != php_stream_write(entry.fp, phar->alias, phar->alias_len)) { in phar_tar_flush()
1010 php_stream_close(entry.fp); in phar_tar_flush()
1011 efree(entry.filename); in phar_tar_flush()
1015 entry.uncompressed_filesize = phar->alias_len; in phar_tar_flush()
1017 …zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeo… in phar_tar_flush()
1082 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1083 if (entry.fp == NULL) { in phar_tar_flush()
1087 entry.uncompressed_filesize = len + 5; in phar_tar_flush()
1089 if ((size_t)len != php_stream_write(entry.fp, user_stub, len) in phar_tar_flush()
1090 || 5 != php_stream_write(entry.fp, " ?>\r\n", 5)) { in phar_tar_flush()
1097 php_stream_close(entry.fp); in phar_tar_flush()
1101 entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); in phar_tar_flush()
1102 entry.filename_len = sizeof(".phar/stub.php")-1; in phar_tar_flush()
1103 …zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeo… in phar_tar_flush()
1110 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1111 if (entry.fp == NULL) { in phar_tar_flush()
1115 if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { in phar_tar_flush()
1116 php_stream_close(entry.fp); in phar_tar_flush()
1123 entry.uncompressed_filesize = entry.compressed_filesize = sizeof(newstub) - 1; in phar_tar_flush()
1124 entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); in phar_tar_flush()
1125 entry.filename_len = sizeof(".phar/stub.php")-1; in phar_tar_flush()
1129 …if (NULL == zend_hash_str_add_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&ent… in phar_tar_flush()
1130 php_stream_close(entry.fp); in phar_tar_flush()
1131 efree(entry.filename); in phar_tar_flush()
1138 php_stream_close(entry.fp); in phar_tar_flush()
1139 efree(entry.filename); in phar_tar_flush()
1142 …zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeo… in phar_tar_flush()
1239 entry.filename = ".phar/signature.bin"; in phar_tar_flush()
1240 entry.filename_len = sizeof(".phar/signature.bin")-1; in phar_tar_flush()
1241 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1242 if (entry.fp == NULL) { in phar_tar_flush()
1260 …if (8 != php_stream_write(entry.fp, sigbuf, 8) || signature_length != php_stream_write(entry.fp, s… in phar_tar_flush()
1274 entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8; in phar_tar_flush()
1276 entry.filename_len = phar_tar_writeheaders_int(&entry, (void *)&pass); in phar_tar_flush()