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()
186 …entry->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()
279 size = entry.uncompressed_filesize = entry.compressed_filesize = in phar_parse_tarfile()
371 entry.filename_len = entry.uncompressed_filesize; in phar_parse_tarfile()
374 if (entry.filename_len == UINT_MAX || entry.filename_len == 0) { in phar_parse_tarfile()
382 entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent); in phar_parse_tarfile()
384 read = php_stream_read(fp, entry.filename, entry.filename_len); in phar_parse_tarfile()
385 if (read != entry.filename_len) { in phar_parse_tarfile()
386 efree(entry.filename); in phar_parse_tarfile()
394 entry.filename[entry.filename_len] = '\0'; in phar_parse_tarfile()
402 efree(entry.filename); in phar_parse_tarfile()
414 efree(entry.filename); in phar_parse_tarfile()
441 entry.filename_len = i+j; in phar_parse_tarfile()
443 if (name[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
445 entry.filename_len--; in phar_parse_tarfile()
447 entry.filename = pestrndup(name, entry.filename_len, myphar->is_persistent); in phar_parse_tarfile()
457 entry.filename_len = i; in phar_parse_tarfile()
458 entry.filename = pestrndup(hdr->name, i, myphar->is_persistent); in phar_parse_tarfile()
460 if (i > 0 && entry.filename[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
462 entry.filename[entry.filename_len - 1] = '\0'; in phar_parse_tarfile()
463 entry.filename_len--; in phar_parse_tarfile()
468 phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len); in phar_parse_tarfile()
472 … error: \"%s\" is a corrupted tar file (checksum mismatch of file \"%s\")", fname, entry.filename); in phar_parse_tarfile()
474 pefree(entry.filename, myphar->is_persistent); in phar_parse_tarfile()
481 entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag); in phar_parse_tarfile()
482 entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */ in phar_parse_tarfile()
483 entry.fp_type = PHAR_FP; in phar_parse_tarfile()
484 entry.flags = entry_mode & PHAR_ENT_PERM_MASK; in phar_parse_tarfile()
485 entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime)); in phar_parse_tarfile()
486 entry.is_persistent = myphar->is_persistent; in phar_parse_tarfile()
488 if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry_mode)) { in phar_parse_tarfile()
489 entry.tar_type = TAR_DIR; in phar_parse_tarfile()
492 if (entry.tar_type == TAR_DIR) { in phar_parse_tarfile()
493 entry.is_dir = 1; in phar_parse_tarfile()
495 entry.is_dir = 0; in phar_parse_tarfile()
498 entry.link = NULL; in phar_parse_tarfile()
502 if (entry.tar_type == TAR_LINK) { in phar_parse_tarfile()
507 pefree(entry.filename, entry.is_persistent); in phar_parse_tarfile()
512 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
513 } else if (entry.tar_type == TAR_SYMLINK) { in phar_parse_tarfile()
514 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
516 phar_set_inode(&entry); in phar_parse_tarfile()
518 …entry = zend_hash_str_update_mem(&myphar->manifest, entry.filename, entry.filename_len, (void*)&en… in phar_parse_tarfile()
521 if (entry.is_persistent) { in phar_parse_tarfile()
522 ++entry.manifest_pos; in phar_parse_tarfile()
525 …if (entry.filename_len >= sizeof(".phar/.metadata")-1 && !memcmp(entry.filename, ".phar/.metadata"… in phar_parse_tarfile()
528 …ar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"", fname, entry.filename); in phar_parse_tarfile()
536 …if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename,… in phar_parse_tarfile()
719 static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* {{{ */ in phar_tar_writeheaders_int() argument
726 if (entry->is_mounted) { in phar_tar_writeheaders_int()
730 if (entry->is_deleted) { in phar_tar_writeheaders_int()
731 if (entry->fp_refcount <= 0) { in phar_tar_writeheaders_int()
739 phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len); in phar_tar_writeheaders_int()
742 if (entry->filename_len > 100) { in phar_tar_writeheaders_int()
744 if (entry->filename_len > 256) { in phar_tar_writeheaders_int()
746 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
750 boundary = entry->filename + entry->filename_len - 101; in phar_tar_writeheaders_int()
754 if (!*boundary || ((boundary - entry->filename) > 155)) { in phar_tar_writeheaders_int()
756 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
760 memcpy(header.prefix, entry->filename, boundary - entry->filename); in phar_tar_writeheaders_int()
761 memcpy(header.name, boundary + 1, entry->filename_len - (boundary + 1 - entry->filename)); in phar_tar_writeheaders_int()
763 memcpy(header.name, entry->filename, entry->filename_len); in phar_tar_writeheaders_int()
766 phar_tar_octal(header.mode, entry->flags & PHAR_ENT_PERM_MASK, sizeof(header.mode)-1); in phar_tar_writeheaders_int()
768 if (FAILURE == phar_tar_octal(header.size, entry->uncompressed_filesize, sizeof(header.size)-1)) { in phar_tar_writeheaders_int()
770 … be created, filename \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
775 if (FAILURE == phar_tar_octal(header.mtime, entry->timestamp, sizeof(header.mtime)-1)) { in phar_tar_writeheaders_int()
777 …fication time of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
783 header.typeflag = entry->tar_type; in phar_tar_writeheaders_int()
785 if (entry->link) { in phar_tar_writeheaders_int()
786 if (strlcpy(header.linkname, entry->link, sizeof(header.linkname)) >= sizeof(header.linkname)) { in phar_tar_writeheaders_int()
788 …ar \"%s\" cannot be created, link \"%s\" is too long for format", entry->phar->fname, entry->link); in phar_tar_writeheaders_int()
797 entry->crc32 = phar_tar_checksum((char *)&header, sizeof(header)); in phar_tar_writeheaders_int()
799 if (FAILURE == phar_tar_octal(header.checksum, entry->crc32, sizeof(header.checksum)-1)) { in phar_tar_writeheaders_int()
801 …ted, checksum of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
807 entry->header_offset = php_stream_tell(fp->new); in phar_tar_writeheaders_int()
811 …nnot be created, header for file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
819 if (entry->uncompressed_filesize) { in phar_tar_writeheaders_int()
820 if (FAILURE == phar_open_entry_fp(entry, fp->error, 0)) { in phar_tar_writeheaders_int()
824 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { in phar_tar_writeheaders_int()
826 …ed, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
831 …if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp->new, entry->uncompressed_f… in phar_tar_writeheaders_int()
833 …nnot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
839 …php_stream_write(fp->new, padding, ((entry->uncompressed_filesize +511)&~511) - entry->uncompresse… in phar_tar_writeheaders_int()
842 if (!entry->is_modified && entry->fp_refcount) { in phar_tar_writeheaders_int()
844 switch (entry->fp_type) { in phar_tar_writeheaders_int()
855 entry->is_modified = 0; in phar_tar_writeheaders_int()
857 if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) { in phar_tar_writeheaders_int()
858 if (!entry->fp_refcount) { in phar_tar_writeheaders_int()
859 php_stream_close(entry->fp); in phar_tar_writeheaders_int()
861 entry->fp = NULL; in phar_tar_writeheaders_int()
864 entry->fp_type = PHAR_FP; in phar_tar_writeheaders_int()
867 entry->offset = entry->offset_abs = pos; in phar_tar_writeheaders_int()
878 int phar_tar_setmetadata(const phar_metadata_tracker *tracker, phar_entry_info *entry, char **error… in phar_tar_setmetadata() argument
882 phar_metadata_tracker_copy(&entry->metadata_tracker, tracker, entry->is_persistent); in phar_tar_setmetadata()
883 …phar_metadata_tracker_try_ensure_has_serialized_data(&entry->metadata_tracker, entry->is_persisten… in phar_tar_setmetadata()
884 serialized_str = entry->metadata_tracker.str; in phar_tar_setmetadata()
887 …entry->uncompressed_filesize = entry->compressed_filesize = serialized_str ? ZSTR_LEN(serialized_s… in phar_tar_setmetadata()
889 if (entry->fp && entry->fp_type == PHAR_MOD) { in phar_tar_setmetadata()
890 php_stream_close(entry->fp); in phar_tar_setmetadata()
893 entry->fp_type = PHAR_MOD; in phar_tar_setmetadata()
894 entry->is_modified = 1; in phar_tar_setmetadata()
895 entry->fp = php_stream_fopen_tmpfile(); in phar_tar_setmetadata()
896 entry->offset = entry->offset_abs = 0; in phar_tar_setmetadata()
897 if (entry->fp == NULL) { in phar_tar_setmetadata()
901 …if (serialized_str && ZSTR_LEN(serialized_str) != php_stream_write(entry->fp, ZSTR_VAL(serialized_… in phar_tar_setmetadata()
902 …ror, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename); in phar_tar_setmetadata()
903 zend_hash_str_del(&(entry->phar->manifest), entry->filename, entry->filename_len); in phar_tar_setmetadata()
916 phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv), *metadata, newentry = {0}; in phar_tar_setupmetadata() local
918 …if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata"… in phar_tar_setupmetadata()
919 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_setupmetadata()
920 return phar_tar_setmetadata(&entry->phar->metadata_tracker, entry, error); in phar_tar_setupmetadata()
923 …entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_str… in phar_tar_setupmetadata()
931 if (!entry->is_modified) { in phar_tar_setupmetadata()
936 lookfor_len = spprintf(&lookfor, 0, ".phar/.metadata/%s/.metadata.bin", entry->filename); in phar_tar_setupmetadata()
938 if (!phar_metadata_tracker_has_data(&entry->metadata_tracker, entry->is_persistent)) { in phar_tar_setupmetadata()
939 zend_hash_str_del(&(entry->phar->manifest), lookfor, lookfor_len); in phar_tar_setupmetadata()
944 if (NULL != (metadata = zend_hash_str_find_ptr(&(entry->phar->manifest), lookfor, lookfor_len))) { in phar_tar_setupmetadata()
946 ret = phar_tar_setmetadata(&entry->metadata_tracker, metadata, error); in phar_tar_setupmetadata()
953 newentry.phar = entry->phar; in phar_tar_setupmetadata()
957 …if (NULL == (metadata = zend_hash_str_add_mem(&(entry->phar->manifest), lookfor, lookfor_len, (voi… in phar_tar_setupmetadata()
959 … "phar tar error: unable to add magic metadata file to manifest for file \"%s\"", entry->filename); in phar_tar_setupmetadata()
963 return phar_tar_setmetadata(&entry->metadata_tracker, metadata, error); in phar_tar_setupmetadata()
969 phar_entry_info entry = {0}; in phar_tar_flush() local
978 entry.flags = PHAR_ENT_PERM_DEF_FILE; in phar_tar_flush()
979 entry.timestamp = time(NULL); in phar_tar_flush()
980 entry.is_modified = 1; in phar_tar_flush()
981 entry.is_crc_checked = 1; in phar_tar_flush()
982 entry.is_tar = 1; in phar_tar_flush()
983 entry.tar_type = '0'; in phar_tar_flush()
984 entry.phar = phar; in phar_tar_flush()
985 entry.fp_type = PHAR_MOD; in phar_tar_flush()
986 entry.fp = NULL; in phar_tar_flush()
987 entry.filename = NULL; in phar_tar_flush()
1002 entry.filename = estrndup(".phar/alias.txt", sizeof(".phar/alias.txt")-1); in phar_tar_flush()
1003 entry.filename_len = sizeof(".phar/alias.txt")-1; in phar_tar_flush()
1004 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1005 if (entry.fp == NULL) { in phar_tar_flush()
1006 efree(entry.filename); in phar_tar_flush()
1010 if (phar->alias_len != php_stream_write(entry.fp, phar->alias, phar->alias_len)) { in phar_tar_flush()
1014 php_stream_close(entry.fp); in phar_tar_flush()
1015 efree(entry.filename); in phar_tar_flush()
1019 entry.uncompressed_filesize = phar->alias_len; in phar_tar_flush()
1021 …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()