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