Skip to content

Commit a596e05

Browse files
authored
phar: Make phar_is_tar() and referenced functions const correct (#20451)
1 parent 618e576 commit a596e05

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

ext/phar/phar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l
17191719
}
17201720

17211721
if (got >= 512) {
1722-
if (phar_is_tar((char *) pos, fname)) { /* TODO: fix const correctness */
1722+
if (phar_is_tar(pos, fname)) {
17231723
php_stream_rewind(fp);
17241724
return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, compression, error);
17251725
}

ext/phar/phar_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ zend_result phar_open_archive_fp(phar_archive_data *phar);
443443
zend_result phar_copy_on_write(phar_archive_data **pphar);
444444

445445
/* tar functions in tar.c */
446-
bool phar_is_tar(char *buf, char *fname);
446+
bool phar_is_tar(const char *buf, const char *fname);
447447
zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, uint32_t compression, char **error);
448448
ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error);
449449
ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) void phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error);

ext/phar/tar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ static zend_result phar_tar_octal(char *buf, uint32_t val, size_t len) /* {{{ */
8787
}
8888
/* }}} */
8989

90-
static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */
90+
static uint32_t phar_tar_checksum(const char *buf, size_t len) /* {{{ */
9191
{
9292
uint32_t sum = 0;
93-
char *end = buf + len;
93+
const char *end = buf + len;
9494

9595
while (buf != end) {
9696
sum += (unsigned char)*buf;
@@ -100,7 +100,7 @@ static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */
100100
}
101101
/* }}} */
102102

103-
bool phar_is_tar(char *buf, char *fname) /* {{{ */
103+
bool phar_is_tar(const char *buf, const char *fname) /* {{{ */
104104
{
105105
tar_header *header = (tar_header *) buf;
106106
uint32_t checksum = phar_tar_number(header->checksum, sizeof(header->checksum));

0 commit comments

Comments
 (0)