php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26035 Opening existing CDB does not work
Submitted: 2003-10-30 05:30 UTC Modified: 2003-12-15 16:34 UTC
From: a dot stagl at gmx dot at Assigned: helly (profile)
Status: Closed Package: DBM/DBA related
PHP Version: 4CVS, 5CVS OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: a dot stagl at gmx dot at
New email:
PHP Version: OS:

 

 [2003-10-30 05:30 UTC] a dot stagl at gmx dot at
Description:
------------
I'm trying to open the contacts-databse from a nokia 9210i mobile, but it doesn't work.


Reproduce code:
---------------
$db_conn = dba_open("contacts.cdb","r","cdb");
if (!$db_conn) die ("opening failed");
$key = dba_firstkey ($db_conn);
while ($key != false)
{
  echo $key."<br />";
  echo dba_fetch ($key, $db_conn)."<br /><br />";
  $key = dba_nextkey ($db_conn);
}
dba_close($db_conn);

Expected result:
----------------
...to get a list of key-value pairs.

Actual result:
--------------
The code didn't produce the expected output nor any error message. It seems that the commands dba_firstkey and dba_nextkey always return false instead of a key.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-31 03:55 UTC] a dot stagl at gmx dot at
Unfortunatly, I cannot provide you the DB which I'm refering to, because - as already mentioned - it is the contacts-database from a nokia 9210i which contains sensitive data. I tried to get a sample contacts.cdb directly from nokia, but they haven't been supportive :-(

But I found the following two cdb-databases on the internet:

http://web.mit.edu/cascon/updates/cascon.cdb (does not work with the provided code)

http://cvs.sourceforge.net/viewcvs.py/*checkout*/cdbfile/cdbFile/cdbFile/Attic/test.cdb?rev=1.1.1.1 (works fine with my code)

HTH
 [2003-10-31 08:26 UTC] sniper@php.net
It actually returns empty string. When you change the
check to while ($key !== false) it'll crash:

(gdb) bt
#0  0x4072cf51 in kill () from /lib/i686/libc.so.6
#1  0x082762ac in _emalloc (size=1735290733, __zend_filename=0x8327600 "/usr/src/web/php/php4/ext/dba/dba_cdb.c", 
    __zend_lineno=303, __zend_orig_filename=0x84a6220 "/usr/src/web/php/php4/Zend/zend_alloc.c", __zend_orig_lineno=218)
    at /usr/src/web/php/php4/Zend/zend_alloc.c:166
#2  0x082765c1 in _safe_emalloc (nmemb=1735290732, size=1, offset=1, 
    __zend_filename=0x8327600 "/usr/src/web/php/php4/ext/dba/dba_cdb.c", __zend_lineno=303, __zend_orig_filename=0x0, 
    __zend_orig_lineno=0) at /usr/src/web/php/php4/Zend/zend_alloc.c:218
#3  0x080bce64 in dba_nextkey_cdb (info=0x864eb74, newlen=0xbfffd4ec) at /usr/src/web/php/php4/ext/dba/dba_cdb.c:303
#4  0x080bbfa4 in zif_dba_nextkey (ht=1, return_value=0x86401ec, this_ptr=0x0, return_value_used=1)
    at /usr/src/web/php/php4/ext/dba/dba.c:914

Assigned to Marcus who added this thing.

 [2003-10-31 08:28 UTC] sniper@php.net
OTOH, I don't think that Nokia/Cascon are using the CDB but something of their own invention.

 [2003-12-15 16:34 UTC] helly@php.net
- The cascon database is not a CDB database.
- The failure is in malloc (safe_emalloc) 
  which tries to allocate more memory then available.
  This cannot be fixed within dba.
- The workaround to check the file length would slowdown
  CDB by adding 2 additional seeks. This contradicts its
  design.
- Hence there is nothing to fixed -> closed

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 20:01:27 2024 UTC