Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ext/phar/phar.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "func_interceptors.h"
#include "ext/standard/crc32.h"
#include "ext/standard/php_var.h"
#include "ext/standard/php_string.h" /* For php_stristr() */
#include "ext/standard/info.h"
#include "zend_smart_str.h"

Expand Down Expand Up @@ -53,8 +52,9 @@ static int phar_set_writeable_bit(zval *zv, void *argument) /* {{{ */
ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
{
bool old, ini;
bool modifying_readonly_ini = ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1;

if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) {
if (modifying_readonly_ini) {
old = PHAR_G(readonly_orig);
} else {
old = PHAR_G(require_hash_orig);
Expand All @@ -64,7 +64,7 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */

/* do not allow unsetting in runtime */
if (stage == ZEND_INI_STAGE_STARTUP) {
if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) {
if (modifying_readonly_ini) {
PHAR_G(readonly_orig) = ini;
} else {
PHAR_G(require_hash_orig) = ini;
Expand All @@ -73,7 +73,7 @@ ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
return FAILURE;
}

if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) {
if (modifying_readonly_ini) {
PHAR_G(readonly) = ini;
if (PHAR_G(request_init) && HT_IS_INITIALIZED(&PHAR_G(phar_fname_map))) {
zend_hash_apply_with_argument(&(PHAR_G(phar_fname_map)), phar_set_writeable_bit, (void *)&ini);
Expand Down Expand Up @@ -2536,7 +2536,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *phar, zen
}

if (user_stub) {
char *pos = php_stristr(ZSTR_VAL(user_stub), halt_stub, ZSTR_LEN(user_stub), strlen(halt_stub));
const char *pos = php_memnistr(ZSTR_VAL(user_stub), halt_stub, strlen(halt_stub), ZSTR_VAL(user_stub)+ZSTR_LEN(user_stub));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'd just leave the line as-is, the php_memnistr is inlined aggressively and is quite long, so it introduces code bloat. By using php_stristr that bloat is kept inside php_stristr


if (pos == NULL) {
if (must_close_old_file) {
Expand Down
Loading