#23778 [Opn->Fbk]: The keys in dba_fetch() and dba_exists() require a terminating null character.

From: Date: Fri, 23 May 2003 13:41:40 +0000
Subject: #23778 [Opn->Fbk]: The keys in dba_fetch() and dba_exists() require a terminating null character.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40270@lists.php.net to get a copy of this message
 ID:               23778
 Updated by:       derick@php.net
 Reported By:      bnies at bluewin dot ch
-Status:           Open
+Status:           Feedback
 Bug Type:         DBM/DBA related
 Operating System: SunOS ducati 5.8 Generic_108528-
 PHP Version:      4.3.1
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2003-05-23 08:22:02] bnies at bluewin dot ch

When doing a dba_exists() or dba_fetch() on a ndbm database then one
has to attach a "\0" character to the key string that it matches.

Configuration:

./configure --prefix=/opt/apache \
            --with-apxs2=/opt/apache/bin/apxs \
            --enable-safe-mode \
            --with-openssl=/opt/openssl \
            --with-ldap=/opt/openldap \
            --with-imap=/opt/uw-imap \
            --with-config-file-path=/opt/apache/conf \
            --enable-dba \
            --with-dbm \
            --with-ndbm

Script that explains the problem:

$alias = "some string";
$id = dba_open($ALIASES_FILE, 'r', 'ndbm');
$key = dba_firstkey($id); # $key contains trailing \0 char
print dba_fetch($alias, $id); # does not match
print dba_fetch("$alias\0", $id); # works
dba_close($id);

Don't know whether it works with other dba handlers or other PHP
version.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=23778&edit=1



Thread (4 messages)

« previous php.bugs (#40270) next »