xref: /PHP-8.2/ext/dba/tests/bug38698.phpt (revision b5a14e6c)
1--TEST--
2Bug #38698 (Bug #38698 for some keys cdbmake creates corrupted db and cdb can't read valid db)
3--EXTENSIONS--
4dba
5--SKIPIF--
6<?php
7    $handler = 'cdb_make';
8    require_once(__DIR__ .'/skipif.inc');
9?>
10--FILE--
11<?php
12
13function isLittleEndian() {
14    return 0x00FF === current(unpack('v', pack('S',0x00FF)));
15}
16
17$db_file = __DIR__ .'/129php.cdb';
18
19if (($db_make=dba_open($db_file, "n", 'cdb_make'))!==FALSE) {
20    if (isLittleEndian() === FALSE) {
21        dba_insert(pack('V',129), "Booo!", $db_make);
22    } else{
23        dba_insert(pack('i',129), "Booo!", $db_make);
24    }
25    dba_close($db_make);
26    // write md5 checksum of generated database file
27    var_dump(md5_file($db_file));
28    @unlink($db_file);
29} else {
30    echo "Error creating database\n";
31}
32?>
33--EXPECT--
34string(32) "1f34b74bde3744265acfc21e0f30af95"
35