Skip to content

memory leak in ZipArchive->setEncryptionName() #19932

Description

@chongwick

Description

The following code:

<?php
$v_346432 = new ZipArchive();
$v_346433 = __DIR__;
$v_346434 = '/80833.zip';
$v_346435 = $v_346433 . $v_346434;
$v_346436 = ZipArchive::CREATE;
$v_346437 = $v_346432->open($v_346435,$v_346436,);
$v_346470 = __DIR__;
$v_346471 = '/80833.zip';
$v_346472 = $v_346470 . $v_346471;
$v_346439 = $v_346432->setPassword($v_346472,);
$v_346440 = 'test.txt';
$v_346441 = 'This is a test string.';
$v_346442 = $v_346432->addFromString($v_346440,$v_346441,);
$v_346443 = 'test.txt';
$v_346444 = ZipArchive::EM_AES_256;
$v_346445 = 'first_password';
$v_346446 = $v_346432->setEncryptionName($v_346443,$v_346444,$v_346445,);
$v_346447 = 'test2.txt';
$v_346448 = 'This is another test string.';
$v_346449 = $v_346432->addFromString($v_346447,$v_346448,);
$v_346477 = 'test.txt';
$v_346451 = ZipArchive::EM_AES_256;
$v_346452 = 'second_password';
$v_346453 = $v_346432->setEncryptionName($v_346477,$v_346451,$v_346452,);

Resulted in this output:

==2594328==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 15 byte(s) in 1 object(s) allocated from:
    #0 0x66e644 in strdup (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x66e644)
    #1 0x14d56e8511cf in zip_file_set_encryption (/lib/x86_64-linux-gnu/libzip.so.4+0x71cf)
    #2 0x4a56b23 in zim_ZipArchive_setEncryptionName /home/w023dtc/nightly_php/php-src/ext/zip/php_zip.c:2341:6
    #3 0x5f318fb in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:2152:4
    #4 0x5c7091b in execute_ex /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:115722:12
    #5 0x5c72eac in zend_execute /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:121434:2
    #6 0x69f5fc9 in zend_execute_script /home/w023dtc/nightly_php/php-src/Zend/zend.c:1977:3
    #7 0x51d2f5a in php_execute_script_ex /home/w023dtc/nightly_php/php-src/main/main.c:2640:13
    #8 0x51d4098 in php_execute_script /home/w023dtc/nightly_php/php-src/main/main.c:2680:9
    #9 0x6a0aeda in do_cli /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:951:5
    #10 0x6a052bf in main /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:1362:18
    #11 0x14d56e62ad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #12 0x14d56e62ae3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #13 0x607ae4 in _start (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x607ae4)

SUMMARY: AddressSanitizer: 15 byte(s) leaked in 1 allocation(s).
ASAN_OPTIONS="fast_unwind_on_malloc=0" php script.php

PHP Version

nightly

Operating System

ubuntu 22.04

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions