php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26203 Session corrupts .jar file transmission
Submitted: 2003-11-11 10:10 UTC Modified: 2003-11-17 18:04 UTC
From: php_query at mrdoms dot plus dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.2 OS: All
Private report: No CVE-ID: None
 [2003-11-11 10:10 UTC] php_query at mrdoms dot plus dot com
Description:
------------
I have a problem trying to redirect a request for a Java .jar through PHP. I am using PHP 4.3.2 on my Apache test server on Windows, and PHP 4.3.3 on my real Debian webserver. The problem is the same for both setups.

If I access the .jar directly (no PHP) & use a packet sniffer, I get returned:

<HTTP headers, Content-Type: text/html >
CRLF CRLF      // End of header?
190 CRLF       // unknown value
<.jar file>

If I use a simple script with just a readfile, I get returned:

<HTTP headers, Content-Type: text/html >
CRLF CRLF      // End of header?
<.jar file>

This request fails to load in any Java VM, which claims the jar is corrupt. The '190' has mysteriously disappeared.

My real PHP script includes a session to make sure the user is accessing the jar from our web page only (script appended). This gives:

<HTTP headers, Content-Type: text/html >
CRLF CRLF      // End of header?
2000 CRLF      // value now changed!
<.jar file>

This request will work fine with: IE6 & Microsoft VM 1.1, and IE6, Netscape, Mozilla with Sun VM 1.4+. It does not load correctly if I use Opera (any VM), or Java 1.3 (any browswer). Changing session cache controls make no difference.

The main issues are - 
    What is the '190'?
    Why does the plain readfile() not send it?
    Why does the session turn it into '2000' which breaks some browswers?

Thank you for your time,

Dom




Reproduce code:
---------------
<?php
 // This fails always
 header("Content-Type: text/html; charset=ISO-8859-1");
 readfile("tj.jar");
?>

<?php
 // This works always
 header("Content-Type: text/html; charset=ISO-8859-1");
 header("\n\n190\n");
 readfile("../_JAVARES/car/jammer.jar");
?>

<?php
 // This sometimes fails depending on browser/VM
 session_start();
 header("Content-Type: text/html; charset=ISO-8859-1");
 readfile("tj.jar");
?>




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-11 10:12 UTC] php_query at mrdoms dot plus dot com
("../_JAVARES/car/jammer.jar"); should read 'tj.jar' in 2nd sample.
Sorry :)
 [2003-11-17 14:41 UTC] sniper@php.net
RTFM about header() and session. There are couple of dozen user comments about how to set the cache headers correctly in these cases.

 [2003-11-17 15:54 UTC] php_query at mrdoms dot plus dot com
Please note in the submission that there is a deeper issue than the cache headers. The simple script (no session):

<?php
 header("Content-Type: text/html; charset=ISO-8859-1");
 readfile("tj.jar");
?>

DOES NOT WORK FOR ANY BROWSER
The JAVA file is ALWAYS treated as corrupt!
This has nothing to do with session cache headers, it appears to be an issue around the chunk transfer encoding under HTTP 1.1 (the hex number appended to the header). When a session is present, the behaviour is _better_, but by no means right.

There is currently a post on the php.general newsgroup around a similar issue:
-> HTTP1.1 problems maybe? posted by Shawn McKenzie, answered by Chris Shiflett
On his example, he is getting a stray '7d3' in the same place I am seeing the '2000', and it is breaking his code.
 [2003-11-17 18:04 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

I think something like this was fixed in 4.3.4..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 22:01:29 2024 UTC