Skip to content

Commit b3f1af7

Browse files
committed
fixup! Fix ZPP order in ext/phar
1 parent 2d0cec1 commit b3f1af7

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

ext/phar/phar_object.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,17 +3693,18 @@ PHP_METHOD(Phar, offsetSet)
36933693
size_t fname_len, cont_len;
36943694
zval *zresource;
36953695

3696+
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
3697+
&& zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
3698+
RETURN_THROWS();
3699+
}
3700+
36963701
PHAR_ARCHIVE_OBJECT();
36973702

36983703
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
36993704
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
37003705
RETURN_THROWS();
37013706
}
37023707

3703-
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE
3704-
&& zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) {
3705-
RETURN_THROWS();
3706-
}
37073708
if (fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php", sizeof(".phar/stub.php")-1)) {
37083709
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use setStub", phar_obj->archive->fname);
37093710
RETURN_THROWS();
@@ -3730,17 +3731,17 @@ PHP_METHOD(Phar, offsetUnset)
37303731
size_t fname_len;
37313732
phar_entry_info *entry;
37323733

3734+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
3735+
RETURN_THROWS();
3736+
}
3737+
37333738
PHAR_ARCHIVE_OBJECT();
37343739

37353740
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
37363741
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
37373742
RETURN_THROWS();
37383743
}
37393744

3740-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) {
3741-
RETURN_THROWS();
3742-
}
3743-
37443745
if (zend_hash_str_exists(&phar_obj->archive->manifest, fname, (uint32_t) fname_len)) {
37453746
if (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint32_t) fname_len))) {
37463747
if (entry->is_deleted) {
@@ -4013,14 +4014,14 @@ PHP_METHOD(Phar, setMetadata)
40134014
char *error;
40144015
zval *metadata;
40154016

4016-
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
4017-
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
4017+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) {
40184018
RETURN_THROWS();
40194019
}
40204020

40214021
PHAR_ARCHIVE_OBJECT();
40224022

4023-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) {
4023+
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
4024+
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
40244025
RETURN_THROWS();
40254026
}
40264027

@@ -4049,14 +4050,14 @@ PHP_METHOD(Phar, delMetadata)
40494050
{
40504051
char *error;
40514052

4052-
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
4053-
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
4053+
if (zend_parse_parameters_none() == FAILURE) {
40544054
RETURN_THROWS();
40554055
}
40564056

40574057
PHAR_ARCHIVE_OBJECT();
40584058

4059-
if (zend_parse_parameters_none() == FAILURE) {
4059+
if (PHAR_G(readonly) && !phar_obj->archive->is_data) {
4060+
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly");
40604061
RETURN_THROWS();
40614062
}
40624063

0 commit comments

Comments
 (0)