Simplify header-reading logic and support JET3 code pages

Using the notes and RC4 key provided in the HACKING file, decrypt the
database definition page all at once instead of decrypting individual
fields with ad-hoc keys. Use the newly decrypted header to access the
database code page at offset 0x3C, and use this numeric value to
initialize the iconv converter with an appropriate charset name for
popular windows code pages. More encodings can be added later, with
the eventual goal of getting rid of the MDB_JET3_CHARSET environment
variable.

Note that individual columns can have their own code pages but this
issue is not addressed.

An extra field is added to the MdbFile structure - because this
struct is allocated internally, this should not break the public
ABI.

Finally, only set the db_passwd field if it's a JET3 database (see #144)
This commit is contained in:
Evan Miller
2020-12-20 18:02:23 -05:00
parent a8414720e4
commit 134306d1af
3 changed files with 36 additions and 26 deletions

View File

@@ -246,6 +246,7 @@ typedef struct {
unsigned char *free_map;
/* reference count */
int refs;
guint16 code_page;
} MdbFile;
/* offset to row count on data pages...version dependant */