Lines Matching refs:entry
163 static zend_result phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp) /* {{{ */ in phar_tar_process_metadata() argument
169 metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1); in phar_tar_process_metadata()
171 read = php_stream_read(fp, metadata, entry->uncompressed_filesize); in phar_tar_process_metadata()
172 if (read != entry->uncompressed_filesize) { in phar_tar_process_metadata()
178 …phar_parse_metadata_lazy(metadata, &entry->metadata_tracker, entry->uncompressed_filesize, entry->… 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 if (phar_metadata_tracker_has_data(&entry->phar->metadata_tracker, entry->phar->is_persistent)) { in phar_tar_process_metadata()
185 entry->phar->metadata_tracker = entry->metadata_tracker; in phar_tar_process_metadata()
186 entry->metadata_tracker.str = NULL; in phar_tar_process_metadata()
187 ZVAL_UNDEF(&entry->metadata_tracker.val); in phar_tar_process_metadata()
188 …entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && NULL != (mentr… in phar_tar_process_metadata()
194 mentry->metadata_tracker = entry->metadata_tracker; in phar_tar_process_metadata()
195 entry->metadata_tracker.str = NULL; in phar_tar_process_metadata()
196 ZVAL_UNDEF(&entry->metadata_tracker.val); 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()
274 size = entry.uncompressed_filesize = entry.compressed_filesize = in phar_parse_tarfile()
366 entry.filename_len = entry.uncompressed_filesize; in phar_parse_tarfile()
369 if (entry.filename_len == UINT_MAX || entry.filename_len == 0) { in phar_parse_tarfile()
377 entry.filename = pemalloc(entry.filename_len+1, myphar->is_persistent); in phar_parse_tarfile()
379 read = php_stream_read(fp, entry.filename, entry.filename_len); in phar_parse_tarfile()
380 if (read != entry.filename_len) { in phar_parse_tarfile()
381 efree(entry.filename); in phar_parse_tarfile()
389 entry.filename[entry.filename_len] = '\0'; in phar_parse_tarfile()
397 efree(entry.filename); in phar_parse_tarfile()
409 efree(entry.filename); in phar_parse_tarfile()
436 entry.filename_len = i+j; in phar_parse_tarfile()
438 if (name[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
440 entry.filename_len--; in phar_parse_tarfile()
442 entry.filename = pestrndup(name, entry.filename_len, myphar->is_persistent); in phar_parse_tarfile()
452 entry.filename_len = i; in phar_parse_tarfile()
453 entry.filename = pestrndup(hdr->name, i, myphar->is_persistent); in phar_parse_tarfile()
455 if (i > 0 && entry.filename[entry.filename_len - 1] == '/') { in phar_parse_tarfile()
457 entry.filename[entry.filename_len - 1] = '\0'; in phar_parse_tarfile()
458 entry.filename_len--; in phar_parse_tarfile()
463 phar_add_virtual_dirs(myphar, entry.filename, entry.filename_len); in phar_parse_tarfile()
467 … error: \"%s\" is a corrupted tar file (checksum mismatch of file \"%s\")", fname, entry.filename); in phar_parse_tarfile()
469 pefree(entry.filename, myphar->is_persistent); in phar_parse_tarfile()
476 entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag); in phar_parse_tarfile()
477 entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */ in phar_parse_tarfile()
478 entry.fp_type = PHAR_FP; in phar_parse_tarfile()
479 entry.flags = entry_mode & PHAR_ENT_PERM_MASK; in phar_parse_tarfile()
480 entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime)); in phar_parse_tarfile()
481 entry.is_persistent = myphar->is_persistent; in phar_parse_tarfile()
483 if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry_mode)) { in phar_parse_tarfile()
484 entry.tar_type = TAR_DIR; in phar_parse_tarfile()
487 if (entry.tar_type == TAR_DIR) { in phar_parse_tarfile()
488 entry.is_dir = 1; in phar_parse_tarfile()
490 entry.is_dir = 0; in phar_parse_tarfile()
493 entry.link = NULL; in phar_parse_tarfile()
497 if (entry.tar_type == TAR_LINK) { in phar_parse_tarfile()
502 pefree(entry.filename, entry.is_persistent); in phar_parse_tarfile()
507 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
508 } else if (entry.tar_type == TAR_SYMLINK) { in phar_parse_tarfile()
509 entry.link = estrndup(hdr->linkname, linkname_len); in phar_parse_tarfile()
511 phar_set_inode(&entry); in phar_parse_tarfile()
513 …entry = zend_hash_str_update_mem(&myphar->manifest, entry.filename, entry.filename_len, (void*)&en… in phar_parse_tarfile()
516 if (entry.is_persistent) { in phar_parse_tarfile()
517 ++entry.manifest_pos; in phar_parse_tarfile()
520 …if (entry.filename_len >= sizeof(".phar/.metadata")-1 && !memcmp(entry.filename, ".phar/.metadata"… in phar_parse_tarfile()
523 …ar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"", fname, entry.filename); in phar_parse_tarfile()
531 …if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename,… in phar_parse_tarfile()
714 static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* {{{ */ in phar_tar_writeheaders_int() argument
721 if (entry->is_mounted) { in phar_tar_writeheaders_int()
725 if (entry->is_deleted) { in phar_tar_writeheaders_int()
726 if (entry->fp_refcount <= 0) { in phar_tar_writeheaders_int()
734 phar_add_virtual_dirs(entry->phar, entry->filename, entry->filename_len); in phar_tar_writeheaders_int()
737 if (entry->filename_len > 100) { in phar_tar_writeheaders_int()
739 if (entry->filename_len > 256) { in phar_tar_writeheaders_int()
741 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
745 boundary = entry->filename + entry->filename_len - 101; in phar_tar_writeheaders_int()
749 if (!*boundary || ((boundary - entry->filename) > 155)) { in phar_tar_writeheaders_int()
751 …t be created, filename \"%s\" is too long for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
755 memcpy(header.prefix, entry->filename, boundary - entry->filename); in phar_tar_writeheaders_int()
756 memcpy(header.name, boundary + 1, entry->filename_len - (boundary + 1 - entry->filename)); in phar_tar_writeheaders_int()
758 memcpy(header.name, entry->filename, entry->filename_len); in phar_tar_writeheaders_int()
761 phar_tar_octal(header.mode, entry->flags & PHAR_ENT_PERM_MASK, sizeof(header.mode)-1); in phar_tar_writeheaders_int()
763 if (FAILURE == phar_tar_octal(header.size, entry->uncompressed_filesize, sizeof(header.size)-1)) { in phar_tar_writeheaders_int()
765 … be created, filename \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
770 if (FAILURE == phar_tar_octal(header.mtime, entry->timestamp, sizeof(header.mtime)-1)) { in phar_tar_writeheaders_int()
772 …fication time of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
778 header.typeflag = entry->tar_type; in phar_tar_writeheaders_int()
780 if (entry->link) { in phar_tar_writeheaders_int()
781 if (strlcpy(header.linkname, entry->link, sizeof(header.linkname)) >= sizeof(header.linkname)) { in phar_tar_writeheaders_int()
783 …ar \"%s\" cannot be created, link \"%s\" is too long for format", entry->phar->fname, entry->link); in phar_tar_writeheaders_int()
792 entry->crc32 = phar_tar_checksum((char *)&header, sizeof(header)); in phar_tar_writeheaders_int()
794 if (FAILURE == phar_tar_octal(header.checksum, entry->crc32, sizeof(header.checksum)-1)) { in phar_tar_writeheaders_int()
796 …ted, checksum of file \"%s\" is too large for tar file format", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
802 entry->header_offset = php_stream_tell(fp->new); in phar_tar_writeheaders_int()
806 …nnot be created, header for file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
814 if (entry->uncompressed_filesize) { in phar_tar_writeheaders_int()
815 if (FAILURE == phar_open_entry_fp(entry, fp->error, 0)) { in phar_tar_writeheaders_int()
819 if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { in phar_tar_writeheaders_int()
821 …ed, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
826 …if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp->new, entry->uncompressed_f… in phar_tar_writeheaders_int()
828 …nnot be created, contents of file \"%s\" could not be written", entry->phar->fname, entry->filenam… in phar_tar_writeheaders_int()
834 …php_stream_write(fp->new, padding, ((entry->uncompressed_filesize +511)&~511) - entry->uncompresse… in phar_tar_writeheaders_int()
837 if (!entry->is_modified && entry->fp_refcount) { in phar_tar_writeheaders_int()
839 switch (entry->fp_type) { in phar_tar_writeheaders_int()
850 entry->is_modified = 0; in phar_tar_writeheaders_int()
852 if (entry->fp_type == PHAR_MOD && entry->fp != entry->phar->fp && entry->fp != entry->phar->ufp) { in phar_tar_writeheaders_int()
853 if (!entry->fp_refcount) { in phar_tar_writeheaders_int()
854 php_stream_close(entry->fp); in phar_tar_writeheaders_int()
856 entry->fp = NULL; in phar_tar_writeheaders_int()
859 entry->fp_type = PHAR_FP; in phar_tar_writeheaders_int()
862 entry->offset = entry->offset_abs = pos; in phar_tar_writeheaders_int()
873 static int phar_tar_setmetadata(const phar_metadata_tracker *tracker, phar_entry_info *entry, char … in phar_tar_setmetadata() argument
877 phar_metadata_tracker_copy(&entry->metadata_tracker, tracker, entry->is_persistent); in phar_tar_setmetadata()
878 …phar_metadata_tracker_try_ensure_has_serialized_data(&entry->metadata_tracker, entry->is_persisten… in phar_tar_setmetadata()
879 serialized_str = entry->metadata_tracker.str; in phar_tar_setmetadata()
882 …entry->uncompressed_filesize = entry->compressed_filesize = serialized_str ? ZSTR_LEN(serialized_s… in phar_tar_setmetadata()
884 if (entry->fp && entry->fp_type == PHAR_MOD) { in phar_tar_setmetadata()
885 php_stream_close(entry->fp); in phar_tar_setmetadata()
888 entry->fp_type = PHAR_MOD; in phar_tar_setmetadata()
889 entry->is_modified = 1; in phar_tar_setmetadata()
890 entry->fp = php_stream_fopen_tmpfile(); in phar_tar_setmetadata()
891 entry->offset = entry->offset_abs = 0; in phar_tar_setmetadata()
892 if (entry->fp == NULL) { in phar_tar_setmetadata()
896 …if (serialized_str && ZSTR_LEN(serialized_str) != php_stream_write(entry->fp, ZSTR_VAL(serialized_… in phar_tar_setmetadata()
897 …ror, 0, "phar tar error: unable to write metadata to magic metadata file \"%s\"", entry->filename); in phar_tar_setmetadata()
898 zend_hash_str_del(&(entry->phar->manifest), entry->filename, entry->filename_len); in phar_tar_setmetadata()
911 phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv), *metadata, newentry = {0}; in phar_tar_setupmetadata() local
913 …if (entry->filename_len >= sizeof(".phar/.metadata") && !memcmp(entry->filename, ".phar/.metadata"… in phar_tar_setupmetadata()
914 …if (entry->filename_len == sizeof(".phar/.metadata.bin")-1 && !memcmp(entry->filename, ".phar/.met… in phar_tar_setupmetadata()
915 return phar_tar_setmetadata(&entry->phar->metadata_tracker, entry, error); in phar_tar_setupmetadata()
918 …entry->filename_len >= sizeof(".phar/.metadata/") + sizeof("/.metadata.bin") - 1 && !zend_hash_str… in phar_tar_setupmetadata()
926 if (!entry->is_modified) { in phar_tar_setupmetadata()
931 lookfor_len = spprintf(&lookfor, 0, ".phar/.metadata/%s/.metadata.bin", entry->filename); in phar_tar_setupmetadata()
933 if (!phar_metadata_tracker_has_data(&entry->metadata_tracker, entry->is_persistent)) { in phar_tar_setupmetadata()
934 zend_hash_str_del(&(entry->phar->manifest), lookfor, lookfor_len); in phar_tar_setupmetadata()
939 if (NULL != (metadata = zend_hash_str_find_ptr(&(entry->phar->manifest), lookfor, lookfor_len))) { in phar_tar_setupmetadata()
941 ret = phar_tar_setmetadata(&entry->metadata_tracker, metadata, error); in phar_tar_setupmetadata()
948 newentry.phar = entry->phar; in phar_tar_setupmetadata()
952 …if (NULL == (metadata = zend_hash_str_add_mem(&(entry->phar->manifest), lookfor, lookfor_len, (voi… in phar_tar_setupmetadata()
954 … "phar tar error: unable to add magic metadata file to manifest for file \"%s\"", entry->filename); in phar_tar_setupmetadata()
958 return phar_tar_setmetadata(&entry->metadata_tracker, metadata, error); in phar_tar_setupmetadata()
967 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()
1039 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1040 if (entry.fp == NULL) { in phar_tar_flush()
1044 entry.uncompressed_filesize = len + end_sequence_len; in phar_tar_flush()
1047 len != php_stream_write(entry.fp, ZSTR_VAL(user_stub), len) in phar_tar_flush()
1048 || end_sequence_len != php_stream_write(entry.fp, end_sequence, end_sequence_len) in phar_tar_flush()
1053 php_stream_close(entry.fp); in phar_tar_flush()
1057 entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); in phar_tar_flush()
1058 entry.filename_len = sizeof(".phar/stub.php")-1; in phar_tar_flush()
1059 …zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeo… in phar_tar_flush()
1062 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1063 if (entry.fp == NULL) { in phar_tar_flush()
1067 if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { in phar_tar_flush()
1068 php_stream_close(entry.fp); in phar_tar_flush()
1075 entry.uncompressed_filesize = entry.compressed_filesize = sizeof(newstub) - 1; in phar_tar_flush()
1076 entry.filename = estrndup(".phar/stub.php", sizeof(".phar/stub.php")-1); in phar_tar_flush()
1077 entry.filename_len = sizeof(".phar/stub.php")-1; in phar_tar_flush()
1081 …if (NULL == zend_hash_str_add_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&ent… in phar_tar_flush()
1082 php_stream_close(entry.fp); in phar_tar_flush()
1083 efree(entry.filename); in phar_tar_flush()
1090 php_stream_close(entry.fp); in phar_tar_flush()
1091 efree(entry.filename); in phar_tar_flush()
1094 …zend_hash_str_update_mem(&phar->manifest, entry.filename, entry.filename_len, (void*)&entry, sizeo… in phar_tar_flush()
1191 entry.filename = ".phar/signature.bin"; in phar_tar_flush()
1192 entry.filename_len = sizeof(".phar/signature.bin")-1; in phar_tar_flush()
1193 entry.fp = php_stream_fopen_tmpfile(); in phar_tar_flush()
1194 if (entry.fp == NULL) { in phar_tar_flush()
1212 …if (8 != php_stream_write(entry.fp, sigbuf, 8) || signature_length != php_stream_write(entry.fp, s… in phar_tar_flush()
1226 entry.uncompressed_filesize = entry.compressed_filesize = signature_length + 8; in phar_tar_flush()
1228 entry.filename_len = phar_tar_writeheaders_int(&entry, (void *)&pass); in phar_tar_flush()