From:             dmp-php at dplhenterprises dot com
Operating system: Windows 2000
PHP version:      4.3.9
PHP Bug Type:     FTP related
Bug description:  ftp_get() file corruption

Description:
------------
When using ftp_get() or ftp_fget() in FTP_ASCII mode and fetching from an
OpenVMS server runing the UCX FTP server (version appears irrelevant),
extra characters are added to the end of the file.
It appears to be the end of the last complete buffer when the final read
doesn't completely fill the buffer at end of file. 
This does not happen with an IIS FTP server. I have been unable to test
with a *nix server.
I've tried fetching the file with both WS_FTP and the standard Windows FTP
client and neither of them produced corrupt files.

Reproduce code:
---------------
<?php
  $wipfil = 'd:/bcs_mps/_wip/ftpbug.txt';
  $srcfil = 'work$:[mps.r]006.mps';

  $f = ftp_connect( 'bcsaxp.bcs.com' );
  if( !$f )
    die( "Unable to connect to bcsaxp.bcs.com. " 
         . $php_errormsg );

  if( !ftp_login( $f, 'myusername', 'mypass' ))
  {
    $this->close();
    die( "Unable to log in to bcsaxp.bcs.com as " 
         . "myusername " . $php_errormsg );
  }

  if( !ftp_get( $f, $wipfil, $srcfil, FTP_ASCII )) 
    die( "Unable to GET file {$srcfil} " . $php_errormsg );
        
  ftp_close( $f );
?>


Expected result:
----------------
<!-- Test MPS request file -->
<bcs_mps_email>
  <message>
    <to address="[EMAIL PROTECTED]" name="Dave testing throug
daveandlaura" />
    <from address="[EMAIL PROTECTED]" name="MPS Test script"
/>
    <subject>Another test message for MPS</subject>
    <body type="text">
This is the plain text version of this message.
It contains a tabbed table.
Column 1        Column 2
L1-C1   L1-C2
L2-C1   L2-C2      
    </body>
    <body type="html">
      <![CDATA[
        <h3 style="text-align: center; color: blue;">This is the HTML version of
this message</h3>
        It contains an HTML table.
        <table border=1>
          <tr><th>Column 1</th><th>Column 2</th></tr>
          <tr><td>L1-C1</td><td>L1-C2</td></tr>
          <tr><td>L2-C1</td><td>L2-C2</td></tr>
        </table>
      ]]>
    </body>
    <attachment file="sys$login:login.com" type="text/plain"
name="Login.Dcl" />
  </message>
<bcs_mps_email>


Actual result:
--------------
<!-- Test MPS request file -->
<bcs_mps_email>
  <message>
    <to address="[EMAIL PROTECTED]" name="Dave testing throug
daveandlaura" />
    <from address="[EMAIL PROTECTED]" name="MPS Test script"
/>
    <subject>Another test message for MPS</subject>
    <body type="text">
This is the plain text version of this message.
It contains a tabbed table.
Column 1        Column 2
L1-C1   L1-C2
L2-C1   L2-C2      
    </body>
    <body type="html">
      <![CDATA[
        <h3 style="text-align: center; color: blue;">This is the HTML version of
this message</h3>
        It contains an HTML table.
        <table border=1>
          <tr><th>Column 1</th><th>Column 2</th></tr>
          <tr><td>L1-C1</td><td>L1-C2</td></tr>
          <tr><td>L2-C1</td><td>L2-C2</td></tr>
        </table>
      ]]>
    </body>
    <attachment file="sys$login:login.com" type="text/plain"
name="Login.Dcl" />
  </message>
<bcs_mps_email>
n 2
L1-C1   L1-C2
L2-C1   L2-C2      
    </body>
    <body type="html">
      <![CDATA[


-- 
Edit bug report at http://bugs.php.net/?id=30439&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30439&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30439&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30439&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30439&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30439&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30439&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30439&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30439&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30439&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30439&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30439&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30439&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30439&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30439&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30439&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30439&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30439&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30439&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30439&r=mysqlcfg

Reply via email to