php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70458 Memory leak
Submitted: 2015-09-08 08:48 UTC Modified: 2015-09-11 12:33 UTC
From: a6y at xakep dot ru Assigned: michael (profile)
Status: Closed Package: expect (PECL)
PHP Version: 5.4.45 OS: Linux 3.2.0-4-amd64 #1 S
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: a6y at xakep dot ru
New email:
PHP Version: OS:

 

 [2015-09-08 08:48 UTC] a6y at xakep dot ru
Description:
------------
Trying to parse result from mulriline response. Php tring to allocate icredible memory size
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 18446744073709531321 bytes) in ... on line 38

Test script:
---------------
ini_set ("expect.timeout", 10);
ini_set ("expect.loguser", "Off");

$stream = expect_popen("ssh user@host");

while (true) {
    switch (expect_expectl ($stream, array (
        array ("password:", PASSWORD), // SSH is asking for password
        array ("yes/no)?", YESNO), // SSH is asking whether to store the host entry
        array ("~$ ", SHELL, EXP_EXACT), // We've got the shell!
    ))) {
        case PASSWORD:
            fwrite ($stream, "pwd\n");
            break;

        case YESNO:
            fwrite ($stream, "yes\n");
            break;

        case SHELL:
            fwrite ($stream, "uname -a\n");
            while (true) {
                switch (expect_expectl ($stream, array (
                    array ("~$ ", SHELL, EXP_EXACT), // We've got the shell!
                    array ("^.*[^~]$", UNAME, EXP_REGEXP), // uname -a output
                ), $match)) {
                    case UNAME:
                        $uname = $match;
                        break;

                    case SHELL:
                        // Run update:
                        var_dump($uname);
                        fwrite ($stream, "ls -la\n");
                        while (true) {
                            switch (expect_expectl ($stream, array (
                                array ("~$ ", SHELL, EXP_EXACT), // We've got the shell!
                                array ("[^~]*~$", UNAME, EXP_REGEXP), // uname -a output
                            ), $match1)) {
                                case UNAME:
                                    $uname = $match1;
                                    break;

                                case SHELL:
                                    // Run update:
                                    var_dump($uname);
                                    fwrite ($stream, "exit\n");
                                    break 3;

                                case EXP_TIMEOUT:
                                case EXP_EOF:
                                    var_dump($uname);
                                    break 3;

                                default:
                                    die ("Error has occurred!\n");
                            }
                        }
                        break 2;

                    case EXP_TIMEOUT:
                    case EXP_EOF:
                        break 2;

                    default:
                        die ("Error has occurred!\n");
                }
            }
            break 2;

        case EXP_TIMEOUT:
        case EXP_EOF:
            break 2;

        default:
            die ("Error has occurred!\n");
    }
}

fclose ($stream);

Expected result:
----------------
Not leaking memory


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-11 12:29 UTC] michael@php.net
Automatic comment from SVN on behalf of michael
Revision: http://svn.php.net/viewvc/?view=revision&revision=337807
Log: Fixed #70458
 [2015-09-11 12:33 UTC] michael@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: michael
 [2015-09-11 12:33 UTC] michael@php.net
Fixed in new release (0.3.2).
 [2021-04-06 10:19 UTC] git@php.net
Automatic comment on behalf of 
Revision: https://github.com/php/pecl-system-expect/commit/42f87918469e83589faed89c4ceef0991bf77670
Log: Fixed #70458
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC