[PHP-DEV] PHP 4.0 Bug #9373 Updated: Filesystem read not binary safe?

2001-02-22 Thread sniper

ID: 9373
Updated by: sniper
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: Filesystem function related
Assigned To: 
Comments:

This should be fixed in CVS already. Please try a dev build from 
http://www.php4win.de/

--Jani


Previous Comments:
---

[2001-02-22 05:46:27] [EMAIL PROTECTED]
I've been checking it a bit further, it seems that all filesystem read and write 
functions fail under the windows apache module.

fread and even fgetc will stop at char(26) and also, if they ancounter a 0D 0A (13 10, 
return+linefeed), even fgetc will only return a 0A. This is exactly the same behaviour 
as when it reads a single 0A, so there's no possible workaround. It seems simply 
impossible to read a binary file correctly. Even ftell seems to be in on the joke.

I've made a file containing ' 09 0D 0A 0A '
reading it with:

$curr=ftell($fp);
while ($char=fgetc($fp)) {
  $new=ftell($fp);
  if ($new>($curr+1)) {
echo " 0D";
  }
  echo strtoupper(dechex(ord($char)));
  $curr=$new;
}

returns: 

09 0D 0A 0D 0A

ftell actually counts the nonexisting second 0D

btw. ftell also doesn't start at 0, if you do a fseek($fp, 0) and then a ftell($fp), 
it will return a semirandom number (at least I haven't found out what it is).

---

[2001-02-21 09:05:31] [EMAIL PROTECTED]
Running PHP 4.0.4pl1 as an apache module (php4apache.dll)

When reading and writing files using any function except include() and require() the 
reading and writing seems to stop whenever a char(0) is encountered... I'm not exactly 
sure that is what happens, but textfiles are read and written without problems, binary 
files are cut short.

e.g.:



delivers only a small part of the image, resulting in a broken image tag (usually) or 
the top part of the image (sometimes). Whereas:



does deliver the entire image (or a parse error :)


---



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9373&edit=2


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #9373 Updated: Filesystem read not binary safe?

2001-02-22 Thread auke

ID: 9373
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: Filesystem function related
Description: Filesystem read not binary safe?

I've been checking it a bit further, it seems that all filesystem read and write 
functions fail under the windows apache module.

fread and even fgetc will stop at char(26) and also, if they ancounter a 0D 0A (13 10, 
return+linefeed), even fgetc will only return a 0A. This is exactly the same behaviour 
as when it reads a single 0A, so there's no possible workaround. It seems simply 
impossible to read a binary file correctly. Even ftell seems to be in on the joke.

I've made a file containing ' 09 0D 0A 0A '
reading it with:

$curr=ftell($fp);
while ($char=fgetc($fp)) {
  $new=ftell($fp);
  if ($new>($curr+1)) {
echo " 0D";
  }
  echo strtoupper(dechex(ord($char)));
  $curr=$new;
}

returns: 

09 0D 0A 0D 0A

ftell actually counts the nonexisting second 0D

btw. ftell also doesn't start at 0, if you do a fseek($fp, 0) and then a ftell($fp), 
it will return a semirandom number (at least I haven't found out what it is).

Previous Comments:
---

[2001-02-21 09:05:31] [EMAIL PROTECTED]
Running PHP 4.0.4pl1 as an apache module (php4apache.dll)

When reading and writing files using any function except include() and require() the 
reading and writing seems to stop whenever a char(0) is encountered... I'm not exactly 
sure that is what happens, but textfiles are read and written without problems, binary 
files are cut short.

e.g.:



delivers only a small part of the image, resulting in a broken image tag (usually) or 
the top part of the image (sometimes). Whereas:



does deliver the entire image (or a parse error :)


---


Full Bug description available at: http://bugs.php.net/?id=9373


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]