ID:               12556
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Verified
 Bug Type:         Filesystem function related
 Operating System: Linux
 PHP Version:      4.3.0-dev
 New Comment:

crashes here too..



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

[2002-12-05 10:32:44] [EMAIL PROTECTED]

I just tested this with php4-200212051430 and it still segfaults.

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

[2002-08-18 02:56:19] [EMAIL PROTECTED]

This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.



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

[2002-07-11 03:05:55] [EMAIL PROTECTED]

This example of yours actually crashes with current HEAD..

(gdb) bt
#0  0x4192fdc9 in memchr () from /lib/libc.so.6
#1  0x8559784 in ?? () at md4.c:255
#2  0x41922fa6 in _IO_getline (fp=0x855dd58, buf=0x8559784 "", n=23,
delim=10, extract_delim=1) at iogetline.c:39
#3  0x419227a0 in _IO_fgets (buf=0x8559784 "", n=24, fp=0x855dd58) at
iofgets.c:48
#4  0x82450bd in php_stdiop_gets (stream=0x855e894, buf=0x8559784 "",
size=24)
    at /usr/src/web/php/php4/main/streams.c:696
#5  0x8243e34 in _php_stream_gets (stream=0x855e894, buf=0x8559784 "",
maxlen=24)
    at /usr/src/web/php/php4/main/streams.c:248
#6  0x81cb335 in zif_fgetcsv (ht=2, return_value=0x855e2ac,
this_ptr=0x0, return_value_used=1)
    at /usr/src/web/php/php4/ext/standard/file.c:2070
#7  0x82828b7 in execute (op_array=0x85596fc) at
/usr/src/web/php/php4/Zend/zend_execute.c:1587
#8  0x826fbc4 in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at /usr/src/web/php/php4/Zend/zend.c:810
#9  0x8239951 in php_execute_script (primary_file=0xbffff95c) at
/usr/src/web/php/php4/main/main.c:1388
#10 0x8288e07 in main (argc=2, argv=0xbffff9c4) at
/usr/src/web/php/php4/sapi/cli/php_cli.c:674
#11 0x418e89cb in __libc_start_main (main=0x828829c <main>, argc=2,
argv=0xbffff9c4, init=0x8086d78 <_init>, 
    fini=0x82fed04 <_fini>, rtld_fini=0x4000aea0 <_dl_fini>,
stack_end=0xbffff9bc)
    at ../sysdeps/generic/libc-start.c:92


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

[2001-08-03 12:45:29] [EMAIL PROTECTED]

Ok, I can live with the embedded newlines in fgetcsv even though I
think it is wrong.  No other app will read a csv file this way.  MySQL
for example exports a literal \n for newlines and translates them on
import rather than embedding them.

But, I do think the length should be respected no matter what:

data:
-----------------
6,7,8,line1
1,2,3,"line2
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3
2,4,5,line3

script:
---------------
    $fp=fopen("test.csv", "r");
    while($line=fgetcsv($fp, 24)){
        print_r($line);
    }


Nothing after that quote gets read.  Even after 24 bites have been
read.

It would seem to me that the code which reads an additional line if an
embedded newline is reached should not issue an FP_FGETS with len but
should use len-strlen(temp).  This would make the length param make
more sense.  And then if len was met it should terminate the record and
start all over.

The code in this function is less that understandable with all the
great names like buff and temp floating around.  I tried looking at it
but will leave it to the guys who wrote it.

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


-- 
Edit this bug report at http://bugs.php.net/?id=12556&edit=1

Reply via email to