php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22286 possible problem with fseek/fread under ISAPI on IIS5
Submitted: 2003-02-18 21:19 UTC Modified: 2003-02-19 22:20 UTC
From: moptop69 at ntlworld dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.1 OS: Win2k Pro Sp3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: moptop69 at ntlworld dot com
New email:
PHP Version: OS:

 

 [2003-02-18 21:19 UTC] moptop69 at ntlworld dot com
okay, i've recently come accross a problem on Win2k, after a hardrive crash, i installed the latest PHP release (4.3.0) and tried to run a script that mainly consists of parsing a Python 'pickled' output file into a MySql table format.

Mostly its a continuous fread from start to finish, but in certain areas, i have to check the next byte in the file using this code:

function gtnxt(&$my2ndFnFile, &$i)
{
//  fseek($my2ndFnFile, $i);
  $data=fread($my2ndFnFile,1);
  fseek($my2ndFnFile, $i);
  $d0=ord($data[0]);
  return $d0;
}

and read the byte again after ive checked its byte value with:

function gt_8(&$my2ndFnFile, &$i)
{
//  fseek($my2ndFnFile, $i);
  $data=fread($my2ndFnFile,1);
  $i+=1;
  $d0=ord($data[0]);
  return $d0;
}

the first variable in both functions is the file handle (opened with "rb" options), and the second, $i, is the file pointer, i keep track of it exactly, since its a very exact requirement to parse these files.

the problem i got is this, gtnxt() is returning the correct byte value of the byte @ $i, however, gt_8()is not, it is returning 00 (in every case of it I could see).

I added debug lines into the code so that each time gtnxt() was called followed by a gt_8() the file pointer and the value were commented into the resultant html, so i could see why things were not going correctly.

Once I saw the issue was that the first read of the byte was correct but the second read was incorrect, I suspected the possibility of the fseek in gtnxt() not working correctly, and added in 2 new fseek lines (commented out in the above code) which actually worked slightly better, allowing the script to parse quite readily, but still showing the same problem further on in the script (about 1000 bytes onward).

I uploaded the script as was to the site server, and it ran fine (apache on redhat 7.1 running PHP4.1.2) so i knew the script worked fine.

I upgraded to 4.3.1 just in case (it had come out a day later) but I expected no changes due to the explanantion of the 4.3.1 revision and was correct, the same issue arose.

I downgraded PHP to 4.2.3 running ISAPI with the same results.  I beleive I was running ISAPI under 4.2.1 before the crash when i knew the script worked ok.

Finally I decided to try running the CGI instead of ISAPI and all worked fine.  I upgraded back to 4.3.1 running CGI and everything worked fine again.

The conclusion i came to is that ISAPI has a problem with either fseek() or fread() but I cannot tell which.

One other change that I have not been able to test, is that the 'pickled' file i am parsing has increased in size by 250% from 270k to about 680k which may also be a factor.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-18 22:55 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip


And if that doesn't work either, provide a complete but short example script and data. (Do NOT add anything over 20 lines in the report, provide an url to them instead)

 [2003-02-19 09:31 UTC] noptop69 at ntlworld dot com
seems to work ok now
 [2003-02-19 22:20 UTC] sniper@php.net
fixed in latest stable snapshot -> closed.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 30 17:01:30 2024 UTC