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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

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 Apr 20 04:01:28 2024 UTC