*/
int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, char **error TSRMLS_DC) /* {{{ */
{
-/* static const char newstub[] = "<?php __HALT_COMPILER(); ?>\r\n"; */
- char *newstub;
+ char halt_stub[] = "__HALT_COMPILER();";
+ char *newstub, *tmp;
phar_entry_info *entry, *newentry;
int halt_offset, restore_alias_len, global_flags = 0, closeoldfile;
char *pos, has_dirs = 0;
} else {
free_user_stub = 0;
}
- if ((pos = strstr(user_stub, "__HALT_COMPILER();")) == NULL)
- {
+ tmp = estrndup(user_stub, len);
+ if ((pos = php_stristr(tmp, halt_stub, len, sizeof(halt_stub) - 1)) == NULL) {
+ efree(tmp);
if (closeoldfile) {
php_stream_close(oldfile);
}
}
return EOF;
}
+ pos = user_stub + (pos - tmp);
+ efree(tmp);
len = pos - user_stub + 18;
if ((size_t)len != php_stream_write(newfile, user_stub, len)
|| 5 != php_stream_write(newfile, " ?>\r\n", 5)) {
php_stream *oldfile, *newfile, *stubfile;
int closeoldfile, free_user_stub, signature_length;
struct _phar_pass_tar_info pass;
- char *buf, *signature, sigbuf[8];
+ char *buf, *signature, *tmp, sigbuf[8];
+ char halt_stub[] = "__HALT_COMPILER();";
entry.flags = PHAR_ENT_PERM_DEF_FILE;
entry.timestamp = time(NULL);
free_user_stub = 0;
}
- if ((pos = strstr(user_stub, "__HALT_COMPILER();")) == NULL) {
+ tmp = estrndup(user_stub, len);
+ if ((pos = php_stristr(tmp, halt_stub, len, sizeof(halt_stub) - 1)) == NULL) {
+ efree(tmp);
if (error) {
spprintf(error, 0, "illegal stub for tar-based phar \"%s\"", phar->fname);
}
}
return EOF;
}
+ pos = user_stub + (pos - tmp);
+ efree(tmp);
len = pos - user_stub + 18;
entry.fp = php_stream_fopen_tmpfile();
char *pos;
smart_str main_metadata_str = {0};
static const char newstub[] = "<?php // zip-based phar archive stub file\n__HALT_COMPILER();";
+ char halt_stub[] = "__HALT_COMPILER();";
+ char *tmp;
+
php_stream *stubfile, *oldfile;
php_serialize_data_t metadata_hash;
int free_user_stub, closeoldfile = 0;
free_user_stub = 0;
}
- if ((pos = strstr(user_stub, "__HALT_COMPILER();")) == NULL)
- {
+ tmp = estrndup(user_stub, len);
+ if ((pos = php_stristr(tmp, halt_stub, len, sizeof(halt_stub) - 1)) == NULL) {
+ efree(tmp);
if (error) {
spprintf(error, 0, "illegal stub for zip-based phar \"%s\"", phar->fname);
}
}
return EOF;
}
+ pos = user_stub + (pos - tmp);
+ efree(tmp);
len = pos - user_stub + 18;
entry.fp = php_stream_fopen_tmpfile();