Skip to content

Commit d7eef8c

Browse files
committed
ext/phar: use zend_string for f404 param of phar_do_404()
1 parent c0856bc commit d7eef8c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ext/phar/phar_object.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,16 @@ static void phar_do_403(void) /* {{{ */
325325
}
326326
/* }}} */
327327

328-
static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, char *f404, size_t f404_len) /* {{{ */
328+
static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, zend_string *f404) /* {{{ */
329329
{
330330
sapi_header_line ctr = {0};
331331
phar_entry_info *info;
332332

333-
if (phar && f404_len) {
334-
info = phar_get_entry_info(phar, f404, f404_len, NULL, true);
333+
if (phar && f404 && ZSTR_LEN(f404)) {
334+
info = phar_get_entry_info(phar, ZSTR_VAL(f404), ZSTR_LEN(f404), NULL, true);
335335

336336
if (info) {
337-
phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, f404, f404_len, fname, NULL, NULL, 0);
337+
phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, ZSTR_VAL(f404), ZSTR_LEN(f404), fname, NULL, NULL, 0);
338338
return;
339339
}
340340
}
@@ -559,8 +559,9 @@ PHP_METHOD(Phar, webPhar)
559559
zval *mimeoverride = NULL;
560560
zend_fcall_info rewrite_fci = {0};
561561
zend_fcall_info_cache rewrite_fcc;
562-
char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL;
563-
size_t alias_len = 0, f404_len = 0, free_pathinfo = 0;
562+
char *alias = NULL, *error, *index_php = NULL, *ru = NULL;
563+
size_t alias_len = 0, free_pathinfo = 0;
564+
zend_string *f404 = NULL;
564565
size_t ru_len = 0;
565566
char *fname, *path_info, *mime_type = NULL, *entry, *pt;
566567
const char *basename;
@@ -571,7 +572,7 @@ PHP_METHOD(Phar, webPhar)
571572
phar_entry_info *info = NULL;
572573
size_t sapi_mod_name_len = strlen(sapi_module.name);
573574

574-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!af!", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) {
575+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!S!af!", &alias, &alias_len, &index_php, &index_php_len, &f404, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) {
575576
RETURN_THROWS();
576577
}
577578

@@ -769,7 +770,7 @@ PHP_METHOD(Phar, webPhar)
769770

770771
if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) ||
771772
(info = phar_get_entry_info(phar, entry, entry_len, NULL, false)) == NULL) {
772-
phar_do_404(phar, fname, fname_len, f404, f404_len);
773+
phar_do_404(phar, fname, fname_len, f404);
773774

774775
if (free_pathinfo) {
775776
efree(path_info);
@@ -815,7 +816,7 @@ PHP_METHOD(Phar, webPhar)
815816

816817
if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) ||
817818
(info = phar_get_entry_info(phar, entry, entry_len, NULL, false)) == NULL) {
818-
phar_do_404(phar, fname, fname_len, f404, f404_len);
819+
phar_do_404(phar, fname, fname_len, f404);
819820
zend_bailout();
820821
}
821822

0 commit comments

Comments
 (0)