php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39170 dbase_open no longer functions
Submitted: 2006-10-16 20:13 UTC Modified: 2006-10-17 23:48 UTC
From: cory dot nemelka at nemelkaitgroup dot com Assigned:
Status: Not a bug Package: dBase related
PHP Version: 5.1.6 OS: RHEL 3.0
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: cory dot nemelka at nemelkaitgroup dot com
New email:
PHP Version: OS:

 

 [2006-10-16 20:13 UTC] cory dot nemelka at nemelkaitgroup dot com
Description:
------------
Since upgrading from PHP v5.0 to PHP v5.1, the dbase_open function no longer works.  The problem appears to be a byte-ordering problem in the "file-type" byte of the header (offset 0).

The problem is illustrated below.  This file opens properly under PHP v5.0 but returns an "unable to get header" under v5.1.

Reproduce code:
---------------
# od -tx1 mattndea.dbf | head
0000000 30 06 0a 04 eb ac 03 00 08 03 33 00 00 00 00 00
0000020 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00
0000040 4d 45 4d 42 45 52 5f 49 44 00 00 43 01 00 00 00
0000060 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000100 44 41 54 45 00 00 00 00 00 00 00 44 0d 00 00 00
0000120 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000140 54 49 4d 45 00 00 00 00 00 00 00 43 15 00 00 00
0000160 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000200 4c 4f 43 41 54 49 4f 4e 00 00 00 43 1c 00 00 00
0000220 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# od -tx2 mattndea.dbf | head
0000000 0630 040a aceb 0003 0308 0033 0000 0000
0000020 0000 0000 0000 0000 0000 0000 0300 0000
0000040 454d 424d 5245 495f 0044 4300 0001 0000
0000060 000c 0000 0000 0000 0000 0000 0000 0000
0000100 4144 4554 0000 0000 0000 4400 000d 0000
0000120 0008 0000 0000 0000 0000 0000 0000 0000
0000140 4954 454d 0000 0000 0000 4300 0015 0000
0000160 0007 0000 0000 0000 0000 0000 0000 0000
0000200 4f4c 4143 4954 4e4f 0000 4300 001c 0000
0000220 0004 0000 0000 0000 0000 0000 0000 0000



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-16 20:24 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2006-10-17 04:08 UTC] cory dot nemelka at nemelkaitgroup dot com
<?php
$dbh=dbase_open("o1.dbf", 0);
$ci = dbase_get_header_info($dbh);
print_r($ci);
?>
 [2006-10-17 04:11 UTC] cory dot nemelka at nemelkaitgroup dot com
You can download a small .dbf file at the following url that should not open:

http://tinyurl.com/yce3bn



NOTE:
The .dbf files that won't open will also not open in Excel or Access (they should).  However, PHP v5.0.3? was able to open these files ok.
 [2006-10-17 04:15 UTC] cory dot nemelka at nemelkaitgroup dot com
Also, to clarify, the dbase_open function works fine with non-Visual Foxpro .dbf files.

If you'd like, I'll dig into this further by downloading the C code for the dbase functions.  

lmk,
--cnemelka
 [2006-10-17 04:48 UTC] cory dot nemelka at nemelkaitgroup dot com
previous version that could read these files was PHP v5.0.4, not v5.0.3.
 [2006-10-17 09:08 UTC] tony2001@php.net
The file is currupted, even dbview is unable to open it.
 [2006-10-17 23:48 UTC] cory dot nemelka at nemelkaitgroup dot com
The smallest production file I have is 17MB (the file shown in hex).  I can post a link if you'd like to look at it.

If not, I'll figure it out sometime in the future and post the answer.  It's clearly a byte-ordering problem.  Since the files can't be opened by Msoft's products, I suspect that it is something local to our environment.  Either way, PHP no longer reads *our* .dbf files.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 11:01:31 2024 UTC