[Pkg-db-devel] Bug#169830: libdb1-compat: db_dump185 is _still_ useless

Julian Gilbey jdg at polya.uklinux.net
Tue Feb 14 23:47:33 UTC 2006


On Wed, Nov 20, 2002 at 01:55:12AM +0000, Colin Watson wrote:
> On Wed, Nov 20, 2002 at 10:06:37AM +0900, Stephen J. Turnbull wrote:
> > Package: libdb1-compat
> > Version: 2.1.3-7
> > Severity: important
> > 
> > Give us a REAL db_dump185, one that doesn't do this:
> > 
> > tleepslib:/vice/db# db_dump185 prot_index.db
> > db_dump185: prot_index.db: Invalid argument
> > 
> > when faced with a database to migrate.

This bug is *evil*.

It goes like this:

main in db_dump185/db_dump185.c calls dbopen in db185/db185.c.

dbopen in turn calls db_open in db/db.c.

db_open attempts to determine the magic number of the file assuming
that the db file begins with a BTMETA structure (the HASHHDR structure
begins identically):

typedef struct _btmeta {
        DB_LSN    lsn;          /* 00-07: LSN. */
        db_pgno_t pgno;         /* 08-11: Current page number. */
        u_int32_t magic;        /* 12-15: Magic number. */
        u_int32_t version;      /* 16-19: Version. */
        [...]

But db1.85 created a file beginning with a slightly different
structure; from libdb 1.85.4 hash/hash.h:

typedef struct hashhdr {                /* Disk resident portion */
        int             magic;          /* Magic NO for hash tables */
        int             version;        /* Version ID */
        [...]

So the magic bytes occur in bytes 0-3.

And it's worse still: the rest of the header is completely different
as well.

What I don't understand is how it could *ever* have worked correctly.

Anyone got any clue?

   Julian




More information about the Pkg-db-devel mailing list