1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

phar: Make phar_is_tar() and referenced functions const correct (#20451)

This commit is contained in:
Niels Dossche
2025-11-11 13:44:13 +01:00
committed by GitHub
parent 618e576614
commit a596e05cf3
3 changed files with 5 additions and 5 deletions

View File

@@ -1719,7 +1719,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l
}
if (got >= 512) {
if (phar_is_tar((char *) pos, fname)) { /* TODO: fix const correctness */
if (phar_is_tar(pos, fname)) {
php_stream_rewind(fp);
return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, compression, error);
}

View File

@@ -443,7 +443,7 @@ zend_result phar_open_archive_fp(phar_archive_data *phar);
zend_result phar_copy_on_write(phar_archive_data **pphar);
/* tar functions in tar.c */
bool phar_is_tar(char *buf, char *fname);
bool phar_is_tar(const char *buf, const char *fname);
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);
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);
ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) void phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error);

View File

@@ -87,10 +87,10 @@ static zend_result phar_tar_octal(char *buf, uint32_t val, size_t len) /* {{{ */
}
/* }}} */
static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */
static uint32_t phar_tar_checksum(const char *buf, size_t len) /* {{{ */
{
uint32_t sum = 0;
char *end = buf + len;
const char *end = buf + len;
while (buf != end) {
sum += (unsigned char)*buf;
@@ -100,7 +100,7 @@ static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */
}
/* }}} */
bool phar_is_tar(char *buf, char *fname) /* {{{ */
bool phar_is_tar(const char *buf, const char *fname) /* {{{ */
{
tar_header *header = (tar_header *) buf;
uint32_t checksum = phar_tar_number(header->checksum, sizeof(header->checksum));