php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52573 SplFileObject::fscanf Segmentation fault
Submitted: 2010-08-10 10:15 UTC Modified: 2010-08-18 04:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ti dot bugmenot at gmail dot com Assigned: felipe
Status: Closed Package: SPL related
PHP Version: PHP 5.3.99-dev (snapshot 201008160630) OS: FreeBSD
Private report: No CVE-ID:
 [2010-08-10 10:15 UTC] ti dot bugmenot at gmail dot com
Description:
------------
Segmentation fault when using additional parameters SplFileObject::fscanf 

Test script:
---------------
<?php // test

error_reporting(E_ALL);

echo "TEST 1:\n";
$f = new SplFileObject(__FILE__, 'r');
$f->fscanf('<?php // %s', $result);
echo $result;

echo "TEST 2:\n";
$result = null;
$f = new SplFileObject(__FILE__, 'r');
$f->fscanf('<?php // %s', $result);
echo $result;

Expected result:
----------------
TEST 1:
test

TEST 2:
test

Actual result:
--------------
TEST 1:
<br />
<b>Notice</b>:  Undefined variable: result in <b>/tmp/fail.php</b> on line <b>7</b><br />
<br />
<b>Notice</b>:  Undefined variable: result in <b>/tmp/fail.php</b> on line <b>8</b><br />


TEST 2:
<br />
<b>Warning</b>:  Parameter 3 to fscanf() expected to be a reference, value given in <b>/tmp/fail.php</b> on line <b>15</b><br />
Segmentation fault


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-11 00:37 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302085
Log: - Fixed bug #52573 (SplFileObject::fscanf Segmentation fault)
 [2010-08-11 00:37 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-08-11 00:37 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-08-16 09:04 UTC] ti dot bugmenot at gmail dot com
-Operating System: +Operating System: FreeBSD -PHP Version: 5.3.3 +PHP Version: PHP 5.3.99-dev (snapshot 201008160630)
 [2010-08-16 09:04 UTC] ti dot bugmenot at gmail dot com
Fail.

CODE:
<?php // test

error_reporting(E_ALL);

echo "TEST 2:\n";
$result = null;
$f = new SplFileObject(__FILE__, 'r');
$f->fscanf('<?php // %s', $result);
echo $result;

/opt/php-trunk/bin/php /tmp/test.php

RESULT:
Warning: Parameter 3 to fscanf() expected to be a reference, value given in /tmp/test.php on line 8


CODE:
<?php // test

error_reporting(E_ALL);

echo "TEST 3:\n";
$result = null;
$f = new SplFileObject(__FILE__, 'r');
$f->fscanf('<?php // %s', &$result);
echo $result;


RESULT:
Fatal error: Call-time pass-by-reference has been removed in /tmp/test.php on line 8

http://snaps.php.net/php-trunk-201008160630.tar.bz2
 [2010-08-18 03:59 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=302420
Log: - Improved fix for bug #52573
 [2010-08-18 04:00 UTC] felipe@php.net
Thanks for the feedback, I've fixed this issue in SVN.

Thanks.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 02:02:11 2014 UTC