#40752 [NEW]: parse_ini_file() segfaults when a scalar setting is redeclared as an array

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40752 [NEW]: parse_ini_file() segfaults when a scalar setting is redeclared as an array

    From: hubert dot roksor at gmail dot com
    Operating system:
    PHP version: 5.2.1
    PHP Bug Type: Reproducible crash
    Bug description: parse_ini_file() segfaults when a scalar setting is redeclared as an array

    Description:
    ------------
    Using [] in a key name can result in a crash if the corresponding setting
    was previously set to a scalar value.

    Reproduce code:
    ---------------
    // Not relevant to the bug
    $file = tempnam('./', '');
    file_put_contents($file, '
    foo =1;
    foo[]=1;
    ');

    // Will make PHP crash
    parse_ini_file($file);


    Expected result:
    ----------------
    In the attached reproduce code we create a ini file which has 2 keys,
    "foo" and "foo[]" then we execute parse_ini_file() on the newly-created
    file.

    Because "Characters {}|&~![()" must not be used anywhere in the key"
    (dixit the manual) I'd expect an error message, or at least a Strict
    notice.

    Actual result:
    --------------
    PHP segfaults/crashes

    (tested on 5.2.1 on WinXP and 5.1.2 on Ubuntu 6.06)

    --
    Edit bug report at [url]http://bugs.php.net/?id=40752&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40752&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40752&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40752&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40752&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40752&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40752&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40752&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40752&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40752&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40752&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40752&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40752&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40752&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40752&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40752&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40752&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40752&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40752&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40752&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40752&r=mysqlcfg[/url]
    hubert dot roksor at gmail dot com Guest

  2. Similar Questions and Discussions

    1. #39454 [NEW]: Returning an array segfaults PHP
      From: aharvey@php.net Operating system: Ubuntu 6.06.1 (AMD64) PHP version: 5.2.0 PHP Bug Type: SOAP related Bug description:...
    2. Array into scalar
      Hi, I have an array derived from a set of radio buttons that I want to break down into a single variable for use with a database. How can I do...
    3. Warning: Cannot use a scalar value as an array in
      Hi all This has just started coming up on a site I run. I haven't changed anything, it just started happening. Unfortunately, it's an adult...
    4. testing for array or scalar in a hash.
      Hi, I have a hash containing, data, everything is generated on the fly so my hash, has some scalars, and some arrays, in it. How can I test wether...
    5. letters in a scalar to array
      hello. i'd like to take the letters in a scalar and make each of them an element in an array. here's what i've got so far.... #!/usr/bin/perl...
  3. #2

    Default #40752 [Opn->Csd]: parse_ini_file() segfaults when a scalar setting is redeclared as an array

    ID: 40752
    Updated by: [email]tony2001@php.net[/email]
    Reported By: hubert dot roksor at gmail dot com
    -Status: Open
    +Status: Closed
    Bug Type: Reproducible crash
    PHP Version: 5.2.1
    New Comment:

    This bug has been fixed in CVS.

    Snapshots of the sources are packaged every three hours; this change
    will be in the next snapshot. You can grab the snapshot at
    [url]http://snaps.php.net/[/url].

    Thank you for the report, and for helping us make PHP better.




    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-08 00:13:41] hubert dot roksor at gmail dot com

    Description:
    ------------
    Using [] in a key name can result in a crash if the corresponding
    setting was previously set to a scalar value.

    Reproduce code:
    ---------------
    // Not relevant to the bug
    $file = tempnam('./', '');
    file_put_contents($file, '
    foo =1;
    foo[]=1;
    ');

    // Will make PHP crash
    parse_ini_file($file);


    Expected result:
    ----------------
    In the attached reproduce code we create a ini file which has 2 keys,
    "foo" and "foo[]" then we execute parse_ini_file() on the newly-created
    file.

    Because "Characters {}|&~![()" must not be used anywhere in the key"
    (dixit the manual) I'd expect an error message, or at least a Strict
    notice.

    Actual result:
    --------------
    PHP segfaults/crashes

    (tested on 5.2.1 on WinXP and 5.1.2 on Ubuntu 6.06)


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40752&edit=1[/url]
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139