php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59439 [PATCH] incorrect header length for date fields
Submitted: 2010-09-28 08:49 UTC Modified: 2010-10-11 02:22 UTC
From: kp at kll dot pl Assigned:
Status: Closed Package: dbase (PECL)
PHP Version: 5.3.2 OS: CentOS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
42 + 19 = ?
Subscribe to this entry?

 
 [2010-09-28 08:49 UTC] kp at kll dot pl
Description:
------------
created dbf has in header 0 as value of length for fileds types date and bool.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-28 08:51 UTC] kp at kll dot pl
patch:

--- dbf_head.c.original 2010-09-28 12:46:04.000000000 +0200
+++ dbf_head.c  2010-09-28 12:46:15.000000000 +0200
@@ -200,9 +200,11 @@
                break;
            case 'D':
                dbf->db_flen = 8;
+               put_short(dbfield.dbf_flen, dbf->db_flen);
                break;
            case 'L':
                dbf->db_flen = 1;
+               put_short(dbfield.dbf_flen, dbf->db_flen);
                break;
            default:
                put_short(dbfield.dbf_flen, dbf->db_flen);
 [2010-09-28 09:07 UTC] kp at kll dot pl
Some DBF tools report created file as corrupted.

Solution is to modify 
file: dbf_head.c
function:  get_dbf_field

before:
-------------------------------
        switch (dbf->db_type) {
            case 'N':
            case 'F':
                        dbf->db_flen = dbfield.dbf_flen[0];
                        dbf->db_fdc = dbfield.dbf_flen[1];
                        break;
            case 'L':
                        dbf->db_flen = 1;
                        break;
            case 'D':
                        dbf->db_flen = 8;
                        break;
            default:
                dbf->db_flen = get_short(dbfield.dbf_flen);
                        break;
        }
-------------------------------

after patch:
-------------------------------
        switch (dbf->db_type) {
            case 'N':
                dbfield.dbf_flen[0] = dbf->db_flen;
                dbfield.dbf_flen[1] = dbf->db_fdc;
                break;
            case 'D':
                dbf->db_flen = 8;
                put_short(dbfield.dbf_flen, dbf->db_flen);
                break;
            case 'L':
                dbf->db_flen = 1;
                put_short(dbfield.dbf_flen, dbf->db_flen);
                break;
            default:
                put_short(dbfield.dbf_flen, dbf->db_flen);
        }
-------------------------------
 [2010-09-28 09:17 UTC] kp at kll dot pl
sorry for above, correct function is: put_dbf_field
and...

before patch:
-------------------------------
       switch (dbf->db_type) {
            case 'N':
                dbfield.dbf_flen[0] = dbf->db_flen;
                dbfield.dbf_flen[1] = dbf->db_fdc;
                break;
            case 'D':
                dbf->db_flen = 8;
                break;
            case 'L':
                dbf->db_flen = 1;
                break;
            default:
                put_short(dbfield.dbf_flen, dbf->db_flen);
        }
-------------------------------


after patch should be:
-------------------------------
        switch (dbf->db_type) {
            case 'N':
                dbfield.dbf_flen[0] = dbf->db_flen;
                dbfield.dbf_flen[1] = dbf->db_fdc;
                break;
            case 'D':
                dbf->db_flen = 8;
                put_short(dbfield.dbf_flen, dbf->db_flen);
                break;
            case 'L':
                dbf->db_flen = 1;
                put_short(dbfield.dbf_flen, dbf->db_flen);
                break;
            default:
                put_short(dbfield.dbf_flen, dbf->db_flen);
        }
-------------------------------
 [2010-09-28 10:38 UTC] alan at akbkhome dot com
Thanks, I'll try and commit it in a few days.
 [2010-09-28 11:33 UTC] kp at kll dot pl
Great, waiting...

It was tested on production server.

In Clipper some RDD like NTX discard this header value but some like ADS relay on it and report corrputed file.

Some other tools may relay on it too.
 [2010-10-11 02:22 UTC] alan at akbkhome dot com
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pecl.php.net/get/dbase


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