#1108292 /usr/bin/gdbm_dump: cannot dump empty key or value

Package:
gdbmtool
Source:
gdbmtool
Description:
GNU dbm database routines (command line tools)
Submitter:
Kacper Gutowski
Date:
2025-06-25 04:41:02 UTC
Severity:
normal
#1108292#5
Date:
2025-06-25 04:38:27 UTC
From:
To:
Dear Maintainer,
GDBM handles the empty (zero bytes long) key and empty values without
any problem, but import/export to flat files is broken. When the empty
key or empty values are present in the database, gdbm_dump produces
output that gdbm_load cannot handle. I suspect the problem is in the
corresponding library functions (and probably applies upstream), but I
only tried the utility programs.

Consider the following:

$ gdbmtool -nN empty_key.db <<< 'store "" "foo";'
$ gdbm_dump empty_key.db empty_key.ascii
$ gdbm_load empty_key.ascii out.db
gdbm_load: empty_key.ascii:10: Malformed data

Likewise:

$ gdbmtool -nN empty_value.db <<< 'store "bar" "";'
$ gdbm_dump empty_value.db empty_value.ascii
$ gdbm_load empty_value.ascii out.db
gdbm_load: empty_value.ascii:11: Unexpected end of file

In both cases, the expected outcome is for gdbm_load to insert
the data from the dump to out.db without error.
The same happens when using binary format with the empty key:

$ gdbm_dump -H binary empty_key.db empty_key.bin
$ gdbm_load empty_key.bin out.db
gdbm_load: cannot load from empty_key.bin: File read error: Success

But binary at least handles empty values correctly:

$ gdbm_dump -H binary empty_value.db empty_value.bin
$ gdbm_load empty_value.bin out.db
# no error