Skip to content

Fix GH-19932: Zip::setEncryptionName()/setEncryptionIndex() memory leak. - #19936

Closed
devnexen wants to merge 4 commits into
php:PHP-8.3from
devnexen:gh19932
Closed

devnexen wants to merge 4 commits into
php:PHP-8.3from
devnexen:gh19932

Conversation

@devnexen

Copy link
Copy Markdown
Member

On successive usage, the password is copied as much but the older address is never freed. Thus, we are hinting a password reset to address it.

… leak.

On successive usage, the password is copied as much but the older
address is never freed. Thus, we are hinting a password reset to address
it.
@devnexen devnexen linked an issue Sep 23, 2025 that may be closed by this pull request
@devnexen
devnexen marked this pull request as ready for review September 24, 2025 04:16

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if this should be fixed in libzip also (i.e. whether libzip should free the old password).
Anyway, judging by https://github.com/nih-at/libzip/blob/3cd08fb38bbcbda24e9f74834c2b70b906d9069f/lib/zip_file_set_encryption.c#L41 this LGTM

@devnexen devnexen closed this in 3ee56f6 Sep 29, 2025
@remicollet

Copy link
Copy Markdown
Member

I wonder if this should be fixed in libzip also (i.e. whether libzip should free the old password). Anyway, judging by https://github.com/nih-at/libzip/blob/3cd08fb38bbcbda24e9f74834c2b70b906d9069f/lib/zip_file_set_encryption.c#L41 this LGTM

Yes, this should be fixed in libzip
So this is only a workaround
See nih-at/libzip#506

devnexen added a commit to devnexen/php-src that referenced this pull request Nov 2, 2025
devnexen added a commit that referenced this pull request Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory leak in ZipArchive->setEncryptionName()

3 participants