/**
* Used for seeking on a phar directory handle
*/
-static int phar_dir_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_dir_seek(php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC) /* {{{ */
{
HashTable *data = (HashTable *)stream->abstract;
size_t to_read;
HashTable *data = (HashTable *)stream->abstract;
zend_string *str_key;
- ulong unused;
+ php_uint_t unused;
if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &str_key, &unused, 0, &data->nInternalPointer)) {
return 0;
char *entry, *found, *save;
zend_string *str_key;
uint keylen;
- ulong unused;
+ php_uint_t unused;
ALLOC_HASHTABLE(data);
zend_hash_init(data, 64, NULL, NULL, 0);
php_stream *ret;
char *internal_file, *error;
zend_string *str_key;
- ulong unused;
+ php_uint_t unused;
phar_archive_data *phar;
phar_entry_info *entry = NULL;
uint host_len;
php_url *resource = NULL;
uint host_len;
zend_string *str_key;
- ulong unused;
+ php_uint_t unused;
uint path_len;
/* pre-readonly check, we need to know if this is a data phar */
static size_t phar_dir_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
static int phar_dir_close(php_stream *stream, int close_handle TSRMLS_DC);
static int phar_dir_flush(php_stream *stream TSRMLS_DC);
-static int phar_dir_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static int phar_dir_seek( php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC);
#else
php_stream* phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
#endif
zend_string *contents;
zend_bool use_include_path = 0;
php_stream *stream;
- long offset = -1;
- long maxlen = PHP_STREAM_COPY_ALL;
+ php_int_t offset = -1;
+ php_int_t maxlen = PHP_STREAM_COPY_ALL;
zval *zcontext = NULL;
if (!PHAR_G(intercepted)) {
}
/* Parse arguments */
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ll", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "p|br!ii", &filename, &filename_len, &use_include_path, &zcontext, &offset, &maxlen) == FAILURE) {
goto skip_phar;
}
}
if (offset > 0 && php_stream_seek(stream, offset, SEEK_SET) < 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", offset);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %pd in the stream", offset);
php_stream_close(stream);
RETURN_FALSE;
}
/* {{{ php_stat
*/
-static void phar_fancy_stat(struct stat *stat_sb, int type, zval *return_value TSRMLS_DC)
+static void phar_fancy_stat(php_stat_t *stat_sb, int type, zval *return_value TSRMLS_DC)
{
zval stat_dev, stat_ino, stat_mode, stat_nlink, stat_uid, stat_gid, stat_rdev,
stat_size, stat_atime, stat_mtime, stat_ctime, stat_blksize, stat_blocks;
switch (type) {
case FS_PERMS:
- RETURN_INT((long)stat_sb->st_mode);
+ RETURN_INT((php_int_t)stat_sb->st_mode);
case FS_INODE:
- RETURN_INT((long)stat_sb->st_ino);
+ RETURN_INT((php_int_t)stat_sb->st_ino);
case FS_SIZE:
- RETURN_INT((long)stat_sb->st_size);
+ RETURN_INT((php_int_t)stat_sb->st_size);
case FS_OWNER:
- RETURN_INT((long)stat_sb->st_uid);
+ RETURN_INT((php_int_t)stat_sb->st_uid);
case FS_GROUP:
- RETURN_INT((long)stat_sb->st_gid);
+ RETURN_INT((php_int_t)stat_sb->st_gid);
case FS_ATIME:
#ifdef NETWARE
- RETURN_INT((long)stat_sb->st_atime.tv_sec);
+ RETURN_INT((php_int_t)stat_sb->st_atime.tv_sec);
#else
- RETURN_INT((long)stat_sb->st_atime);
+ RETURN_INT((php_int_t)stat_sb->st_atime);
#endif
case FS_MTIME:
#ifdef NETWARE
- RETURN_INT((long)stat_sb->st_mtime.tv_sec);
+ RETURN_INT((php_int_t)stat_sb->st_mtime.tv_sec);
#else
- RETURN_INT((long)stat_sb->st_mtime);
+ RETURN_INT((php_int_t)stat_sb->st_mtime);
#endif
case FS_CTIME:
#ifdef NETWARE
- RETURN_INT((long)stat_sb->st_ctime.tv_sec);
+ RETURN_INT((php_int_t)stat_sb->st_ctime.tv_sec);
#else
- RETURN_INT((long)stat_sb->st_ctime);
+ RETURN_INT((php_int_t)stat_sb->st_ctime);
#endif
case FS_TYPE:
if (S_ISLNK(stat_sb->st_mode)) {
if (!IS_ABSOLUTE_PATH(filename, filename_length) && !strstr(filename, "://")) {
char *arch, *entry, *fname;
int arch_len, entry_len, fname_len;
- struct stat sb = {0};
+ php_stat_t sb = {0};
phar_entry_info *data = NULL;
phar_archive_data *phar;
* This is used by phar_open_from_filename to process the manifest, but can be called
* directly.
*/
-static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, long halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
+static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, php_int_t halt_offset, phar_archive_data** pphar, php_uint32 compression, char **error TSRMLS_DC) /* {{{ */
{
char b32[4], *buffer, *endbuffer, *savebuf;
phar_archive_data *mydata = NULL;
phar_entry_info entry;
php_uint32 manifest_len, manifest_count, manifest_flags, manifest_index, tmp_len, sig_flags;
php_uint16 manifest_ver;
- long offset;
+ php_int_t offset;
int sig_len, register_alias = 0, temp_alias = 0;
char *signature = NULL;
/* be ignored on reading because it is being generated anyways. */
if (manifest_flags & PHAR_HDR_SIGNATURE) {
char sig_buf[8], *sig_ptr = sig_buf;
- off_t read_len;
+ php_off_t read_len;
size_t end_of_phar;
if (-1 == php_stream_seek(fp, -8, SEEK_END)
case PHAR_SIG_OPENSSL: {
php_uint32 signature_len;
char *sig;
- off_t whence;
+ php_off_t whence;
/* we store the signature followed by the signature length */
if (-1 == php_stream_seek(fp, -12, SEEK_CUR)
static inline char *phar_strnstr(const char *buf, int buf_len, const char *search, int search_len) /* {{{ */
{
const char *c;
- int so_far = 0;
+ ptrdiff_t so_far = 0;
if (buf_len < search_len) {
return NULL;
char *pos, test = '\0';
const int window_size = 1024;
char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
- const long readsize = sizeof(buffer) - sizeof(token);
- const long tokenlen = sizeof(token) - 1;
- long halt_offset;
+ const php_int_t readsize = sizeof(buffer) - sizeof(token);
+ const php_int_t tokenlen = sizeof(token) - 1;
+ php_int_t halt_offset;
size_t got;
php_uint32 compression = PHAR_FILE_COMPRESSED_NONE;
}
} else {
zend_string *str_key;
- ulong unused;
+ php_uint_t unused;
for (zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map));
HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &str_key, &unused, 0, &PHAR_GLOBALS->phar_fname_map.nInternalPointer);
* user_stub contains either a string, or a resource pointer, if len is a negative length.
* user_stub and len should be both 0 if the default or existing stub should be used
*/
-int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, char **error TSRMLS_DC) /* {{{ */
+int phar_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int convert, char **error TSRMLS_DC) /* {{{ */
{
char halt_stub[] = "__HALT_COMPILER();";
char *newstub, *tmp;
int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
char *pos, has_dirs = 0;
char manifest[18], entry_buffer[24];
- off_t manifest_ftell;
- long offset;
+ php_off_t manifest_ftell;
+ php_int_t offset;
size_t wrote;
php_uint32 manifest_len, mytime, loc, new_manifest_count;
php_uint32 newcrc32;
char *filename;
enum phar_fp_type fp_type;
/* offset within original phar file of the file contents */
- long offset_abs;
+ php_int_t offset_abs;
/* offset within fp of the file contents */
- long offset;
+ php_int_t offset;
/* offset within original phar file of the file header (for zip-based/tar-based) */
- long header_offset;
+ php_int_t header_offset;
php_stream *fp;
php_stream *cfp;
int fp_refcount;
typedef struct _phar_entry_fp_info {
enum phar_fp_type fp_type;
/* offset within fp of the file contents */
- long offset;
+ php_int_t offset;
} phar_entry_fp_info;
struct _phar_entry_fp {
PHAR_GLOBALS->cached_fp[phar->phar_pos].ufp = fp;
}
-static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, off_t offset TSRMLS_DC)
+static inline void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, php_off_t offset TSRMLS_DC)
{
phar_entry_fp_info *data;
return PHAR_GLOBALS->cached_fp[entry->phar->phar_pos].manifest[entry->manifest_pos].fp_type;
}
-static inline off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
+static inline php_off_t phar_get_fp_offset(phar_entry_info *entry TSRMLS_DC)
{
if (!entry->is_persistent) {
return entry->offset;
phar_archive_data *phar;
php_stream *fp;
/* stream position proxy, allows multiple open streams referring to the same fp */
- off_t position;
+ php_off_t position;
/* for copies of the phar fp, defines where 0 is */
- off_t zero;
+ php_off_t zero;
unsigned int for_write:1;
unsigned int is_zip:1;
unsigned int is_tar:1;
phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC);
int phar_parse_metadata(char **buffer, zval *metadata, int zip_metadata_len TSRMLS_DC);
void destroy_phar_manifest_entry(zval *zv);
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC);
+int phar_seek_efp(phar_entry_info *entry, php_off_t offset, int whence, php_off_t position, int follow_links TSRMLS_DC);
php_stream *phar_get_efp(phar_entry_info *entry, int follow_links TSRMLS_DC);
int phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error TSRMLS_DC);
int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TSRMLS_DC);
int phar_is_tar(char *buf, char *fname);
int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, int is_data, php_uint32 compression, char **error TSRMLS_DC);
int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC);
/* zip functions in zip.c */
int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias, int alias_len, phar_archive_data** pphar, char **error TSRMLS_DC);
int phar_open_or_create_zip(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC);
-int phar_zip_flush(phar_archive_data *archive, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC);
+int phar_zip_flush(phar_archive_data *archive, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC);
#ifdef PHAR_MAIN
static int phar_open_from_fp(php_stream* fp, char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, int is_data, char **error TSRMLS_DC);
phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, int path_len, char dir, char **error, int security TSRMLS_DC);
phar_entry_data *phar_get_or_create_entry_data(char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char *path, int path_len, const char *mode, char allow_dir, char **error, int security TSRMLS_DC);
-int phar_flush(phar_archive_data *archive, char *user_stub, long len, int convert, char **error TSRMLS_DC);
+int phar_flush(phar_archive_data *archive, char *user_stub, php_int_t len, int convert, char **error TSRMLS_DC);
int phar_detect_phar_fname_ext(const char *filename, int filename_len, const char **ext_str, int *ext_len, int executable, int for_create, int is_complete TSRMLS_DC);
int phar_split_fname(const char *filename, int filename_len, char **arch, int *arch_len, char **entry, int *entry_len, int executable, int for_create TSRMLS_DC);
zend_op_array *new_op_array;
zval result;
php_stream *fp;
- off_t position;
+ php_off_t position;
switch (code) {
case PHAR_MIME_PHPS:
if (got > 0) {
PHPWRITE(buf, got);
position += got;
- if (position == (off_t) info->uncompressed_filesize) {
+ if (position == (php_off_t) info->uncompressed_filesize) {
break;
}
}
{
char *alias = NULL, *error;
int alias_len = 0;
- long dataoffset = 0;
+ php_int_t dataoffset = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!i", &alias, &alias_len, &dataoffset) == FAILURE) {
return;
}
* Returns whether phar extension supports compression using zlib/bzip2 */
PHP_METHOD(Phar, canCompress)
{
- long method = 0;
+ php_int_t method = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &method) == FAILURE) {
return;
}
#else
char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname;
int fname_len, alias_len = 0, arch_len, entry_len, is_data;
- long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
- long format = 0;
+ php_int_t flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
+ php_int_t format = 0;
phar_archive_object *phar_obj;
phar_archive_data *phar_data;
zval *zobj = getThis(), arg1, arg2;
is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data TSRMLS_CC);
if (is_data) {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|is!i", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) {
return;
}
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|is!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) {
return;
}
}
PHP_METHOD(Phar, count)
{
/* mode can be ignored, maximum depth is 1 */
- long mode;
+ php_int_t mode;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &mode) == FAILURE) {
RETURN_FALSE;
}
*/
PHP_METHOD(Phar, isFileFormat)
{
- long type;
+ php_int_t type;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &type) == FAILURE) {
RETURN_FALSE;
}
static int phar_copy_file_contents(phar_entry_info *entry, php_stream *fp TSRMLS_DC) /* {{{ */
{
char *error;
- off_t offset;
+ php_off_t offset;
phar_entry_info *link;
if (FAILURE == phar_open_entry_fp(entry, &error, 1 TSRMLS_CC)) {
php_uint32 flags;
zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */
- long format = 9021976, method = 9021976;
+ php_int_t format = 9021976, method = 9021976;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iis", &format, &method, &ext, &ext_len) == FAILURE) {
return;
}
php_uint32 flags;
zend_object *ret;
/* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */
- long format = 9021976, method = 9021976;
+ php_int_t format = 9021976, method = 9021976;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls", &format, &method, &ext, &ext_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iis", &format, &method, &ext, &ext_len) == FAILURE) {
return;
}
zval *zstub;
char *stub, *error;
int stub_len;
- long len = -1;
+ php_int_t len = -1;
php_stream *stream;
PHAR_ARCHIVE_OBJECT();
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &zstub, &len) == SUCCESS) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|i", &zstub, &len) == SUCCESS) {
if ((php_stream_from_zval_no_verify(stream, zstub)) != NULL) {
if (len > 0) {
len = -len;
*/
PHP_METHOD(Phar, setSignatureAlgorithm)
{
- long algo;
+ php_int_t algo;
char *error, *key = NULL;
int key_len = 0;
return;
}
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &algo, &key, &key_len) != SUCCESS) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "i|s", &algo, &key, &key_len) != SUCCESS) {
return;
}
*/
PHP_METHOD(Phar, compress)
{
- long method;
+ php_int_t method;
char *ext = NULL;
int ext_len = 0;
php_uint32 flags;
zend_object *ret;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|s", &method, &ext, &ext_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i|s", &method, &ext, &ext_len) == FAILURE) {
return;
}
{
char *error;
php_uint32 flags;
- long method;
+ php_int_t method;
PHAR_ARCHIVE_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &method) == FAILURE) {
return;
}
PHP_METHOD(PharFileInfo, isCompressed)
{
/* a number that is not Phar::GZ or Phar::BZ2 */
- long method = 9021976;
+ php_int_t method = 9021976;
PHAR_ENTRY_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &method) == FAILURE) {
return;
}
PHP_METHOD(PharFileInfo, chmod)
{
char *error;
- long perms;
+ php_int_t perms;
PHAR_ENTRY_OBJECT();
if (entry_obj->entry->is_temp_dir) {
return;
}
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &perms) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &perms) == FAILURE) {
return;
}
*/
PHP_METHOD(PharFileInfo, compress)
{
- long method;
+ php_int_t method;
char *error;
PHAR_ENTRY_OBJECT();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &method) == FAILURE) {
return;
}
got = php_stream_read(data->fp, buf, MIN(count, entry->uncompressed_filesize - data->position));
data->position = php_stream_tell(data->fp) - data->zero;
- stream->eof = (data->position == (off_t) entry->uncompressed_filesize);
+ stream->eof = (data->position == (php_off_t) entry->uncompressed_filesize);
return got;
}
/**
* Used for fseek($fp) on a phar file handle
*/
-static int phar_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC) /* {{{ */
+static int phar_stream_seek(php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC) /* {{{ */
{
phar_entry_data *data = (phar_entry_data *)stream->abstract;
phar_entry_info *entry;
int res;
- off_t temp;
+ php_off_t temp;
if (data->internal_file->link) {
entry = phar_get_link_source(data->internal_file TSRMLS_CC);
default:
temp = 0;
}
- if (temp > data->zero + (off_t) entry->uncompressed_filesize) {
+ if (temp > data->zero + (php_off_t) entry->uncompressed_filesize) {
*newoffset = -1;
return -1;
}
return -1;
}
data->position = php_stream_tell(data->fp);
- if (data->position > (off_t)data->internal_file->uncompressed_filesize) {
+ if (data->position > (php_off_t)data->internal_file->uncompressed_filesize) {
data->internal_file->uncompressed_filesize = data->position;
}
data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize;
static size_t phar_stream_read( php_stream *stream, char *buf, size_t count TSRMLS_DC);
static int phar_stream_close(php_stream *stream, int close_handle TSRMLS_DC);
static int phar_stream_flush(php_stream *stream TSRMLS_DC);
-static int phar_stream_seek( php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC);
+static int phar_stream_seek( php_stream *stream, php_off_t offset, int whence, php_off_t *newoffset TSRMLS_DC);
static int phar_stream_stat( php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
END_EXTERN_C()
phar_tar_number(hdr->size, sizeof(hdr->size));
if (((!old && hdr->prefix[0] == 0) || old) && strlen(hdr->name) == sizeof(".phar/signature.bin")-1 && !strncmp(hdr->name, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
- off_t curloc;
+ php_off_t curloc;
if (size > 511) {
if (error) {
}
/* }}} */
-int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_tar_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
{
phar_entry_info entry = {0};
static const char newstub[] = "<?php // tar-based phar archive stub file\n__HALT_COMPILER();";
#include <openssl/ssl.h>
#include <openssl/pkcs12.h>
#else
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, php_off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
#endif
/* for links to relative location, prepend cwd of the entry */
}
/* }}} */
-int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t position, int follow_links TSRMLS_DC) /* {{{ */
+int phar_seek_efp(phar_entry_info *entry, php_off_t offset, int whence, php_off_t position, int follow_links TSRMLS_DC) /* {{{ */
{
php_stream *fp = phar_get_efp(entry, follow_links TSRMLS_CC);
- off_t temp, eoffset;
+ php_off_t temp, eoffset;
if (!fp) {
return -1;
temp = 0;
}
- if (temp > eoffset + (off_t) entry->uncompressed_filesize) {
+ if (temp > eoffset + (php_off_t) entry->uncompressed_filesize) {
return -1;
}
php_stream_filter *filter;
phar_archive_data *phar = entry->phar;
char *filtername;
- off_t loc;
+ php_off_t loc;
php_stream *ufp;
phar_entry_data dummy;
php_stream_flush(ufp);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
- if (php_stream_tell(ufp) - loc != (off_t) entry->uncompressed_filesize) {
+ if (php_stream_tell(ufp) - loc != (php_off_t) entry->uncompressed_filesize) {
spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
return FAILURE;
}
/* }}} */
#ifndef PHAR_HAVE_OPENSSL
-static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
+static int phar_call_openssl_signverify(int is_sign, php_stream *fp, php_off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC) /* {{{ */
{
zend_fcall_info fci;
zend_fcall_info_cache fcc;
int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error TSRMLS_DC) /* {{{ */
{
int read_size, len;
- off_t read_len;
+ php_off_t read_len;
unsigned char buf[1024];
php_stream_rewind(fp);
while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
EVP_VerifyUpdate (&md_ctx, buf, len);
- read_len -= (off_t)len;
+ read_len -= (php_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA512Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (php_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA256Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (php_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA1Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (php_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_MD5Update(&context, buf, len);
- read_len -= (off_t)len;
+ read_len -= (php_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
{
phar_zip_dir_end locator;
char buf[sizeof(locator) + 65536];
- long size;
+ php_int_t size;
php_uint16 i;
phar_archive_data *mydata = NULL;
phar_entry_info entry = {0};
/* add each central directory item to the manifest */
for (i = 0; i < PHAR_GET_16(locator.count); ++i) {
phar_zip_central_dir_file zipentry;
- off_t beforeus = php_stream_tell(fp);
+ php_off_t beforeus = php_stream_tell(fp);
if (sizeof(zipentry) != php_stream_read(fp, (char *) &zipentry, sizeof(zipentry))) {
PHAR_ZIP_FAIL("unable to read central directory entry, truncated");
if (entry.filename_len == sizeof(".phar/signature.bin")-1 && !strncmp(entry.filename, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
size_t read;
php_stream *sigfile;
- off_t now;
+ php_off_t now;
char *sig;
now = php_stream_tell(fp);
phar_add_virtual_dirs(mydata, entry.filename, entry.filename_len TSRMLS_CC);
if (PHAR_GET_16(zipentry.extra_len)) {
- off_t loc = php_stream_tell(fp);
+ php_off_t loc = php_stream_tell(fp);
if (FAILURE == phar_zip_process_extra(fp, &entry, PHAR_GET_16(zipentry.extra_len) TSRMLS_CC)) {
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("Unable to process extra field header for file in central directory");
if (!actual_alias && entry.filename_len == sizeof(".phar/alias.txt")-1 && !strncmp(entry.filename, ".phar/alias.txt", sizeof(".phar/alias.txt")-1)) {
php_stream_filter *filter;
- off_t saveloc;
+ php_off_t saveloc;
/* verify local file header */
phar_zip_file_header local;
phar_zip_central_dir_file central;
struct _phar_zip_pass *p;
php_uint32 newcrc32;
- off_t offset;
+ php_off_t offset;
int not_really_modified = 0;
p = (struct _phar_zip_pass*) arg;
char *signature, sigbuf[8];
phar_entry_info entry = {0};
php_stream *newfile;
- off_t tell, st;
+ php_off_t tell, st;
newfile = php_stream_fopen_tmpfile();
if (newfile == NULL) {
}
/* }}} */
-int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
+int phar_zip_flush(phar_archive_data *phar, char *user_stub, php_int_t len, int defaultstub, char **error TSRMLS_DC) /* {{{ */
{
char *pos;
smart_str main_metadata_str = {0};