Commit Graph

101 Commits

Author SHA1 Message Date
Evan Miller
f79f942d1f Fix RC4 decryption on big-endian platforms 2021-07-17 10:13:24 -04:00
Evan Miller
fe77bc5c8e Remove uses of ntohl 2021-07-14 09:33:24 -04:00
Benedikt Reinartz
9401d3cd84 Rename function to mdbi_rc4 to prevent it from being exported 2021-05-19 07:45:43 +02:00
Benedikt Reinartz
89ce71637c Re-encrypt pages on write 2021-05-17 07:27:49 +02:00
Benedikt Reinartz
873c6a027e Extract RC4 code to separate file 2021-05-17 07:21:44 +02:00
Evan Miller
fe0175aa63
Migrate to g_memdup2 (#288)
With fakeglib and older versions of GLib, fall back to g_memdup with
a #define inside mdbprivate.h.

Fixes #287
2021-04-05 09:04:29 -04:00
Evan Miller
8f1f080e3f Support Access 2019
Per #260 I am assuming that the internal version 6 refers to files
created with Access 2019. I can't find any documentation on this format,
so I am calling it ACE17. Testing welcome.
2021-03-23 15:56:39 -04:00
Evan Miller
aec667a033 Fix numeric scale/precision on Jet3 databases 2021-01-19 15:23:28 -05:00
Evan Miller
538711e450 Remove unnecessary casts 2020-12-28 22:30:20 -05:00
Evan Miller
3001c3b94f Use the language ID from the DB header for indexing
According to the HACKING file, the file's default language ID is stored
in the database header. Use this value instead of a generic English
language locale for indexing JET4 files.

Columns can have their own text sorting rules, including language ID
distinct from the file's language ID, but this is not addressed as we'd
have to break the mdb_index_hash_text function signature, which I'm not
prepared to do just yet.

There appear to be two bytes after the language ID that may indicate
additional sorting flags. These bytes need additional research.
2020-12-21 09:11:42 -05:00
Evan Miller
b8ec7a2ec7 Use GCC style initializers for MdbFormatConstants 2020-12-20 20:15:13 -05:00
Evan Miller
134306d1af 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)
2020-12-20 18:02:23 -05:00
Evan Miller
38ce7db045 Large file support on 32-bit systems
* Add AC_SYS_LARGEFILE to configure.ac

* Replace fseek with fseeko
2020-11-07 11:40:44 -05:00
Evan Miller
7f7761e884 Improved support for "Short Date" fields
* Separate -D (date only) and -T (date/time) format options in mdb-export and mdb-json

* New public mdb_set_shortdate_fmt() function in libmdb

* New private(ish) mdb_col_is_shortdate() function

I'm calling it "shortdate" in order to preserve the existing API.

See https://github.com/mdbtools/mdbtools/issues/12
2020-09-02 22:14:57 -04:00
Evan Miller
fb960553e6 New mdb_set_bind_size function overrides MDB_BIND_SIZE
This should fix long-standing complaints about the default bind size
without causing undue memory inflation in existing applications.

Could make this adjustable on the command line later.

Supersedes:

https://github.com/mdbtools/mdbtools/pull/137
2020-09-02 14:30:07 -04:00
Evan Miller
be888e0dd7
Support fuzz testing (#4)
Quickstart (requires Clang 6 or later):

$ export LIB_FUZZING_ENGINE=/path/to/fuzzing/library.a
$ ./configure --enable-fuzz-testing
$ make
$ cd src/fuzz
$ make fuzz_mdb
$ ./fuzz_mdb

Also add a new `mdb_open_buffer function` to facilitate in-memory
fuzz-testing. This requires fmemopen, which may not be present on all
systems. The internal API has been reworked to use file streams instead
of file descriptors. This allows reading from memory and reading from
files using a consistent API.
2020-08-31 13:03:58 -04:00
Evan Miller
a08dab706e Fix crash in previous commit 2020-08-21 08:53:05 -04:00
Evan Miller
2ee83971fa Clean up mdb_clone_handle 2020-08-20 21:57:25 -04:00
Evan Miller
4d443840cb Try to fix a crash 2020-08-20 21:31:38 -04:00
Evan Miller
09c497bffd Fix double free with backend dictionary 2020-08-20 20:10:51 -04:00
Evan Miller
b36f2bff1d Merge branch 'master' into backend-thread-safety 2020-08-20 15:22:52 -04:00
Evan Miller
90ee7bfcb5 Remove references to dmalloc
There are more modern tools for memory debugging, get rid of DMALLOC
crap in the source code.

I've left one reference in backend.c to prevent a merge conflict but
this can be removed later.
2020-08-20 08:59:08 -04:00
Evan Miller
588663675e Move backend dictionary and state to MdbHandle
Attempt to make the backend handling logic thread-safe. This removes the
last MDB_CONSTRUCTOR. Also get rid of some JAVA junk and make the
remaining static variables in backend.c constant. Finally remove some
obsolete fields from MdbFile.
2020-08-20 07:58:53 -04:00
Evan Miller
5d078838ed [API break] Make date/boolean formats thread safe
Store the preferred date and boolean formats in the MdbHandle rather
than in global memory.
2020-08-19 21:26:06 -04:00
Evan Miller
1ad0dd2d8b Simplify code 2020-08-18 21:20:40 -04:00
Evan Miller
9941cb2927 More printf portability fixes 2020-08-04 17:34:54 -04:00
Evan Miller
446b92b2c8 printf portability fixes 2020-08-04 17:24:04 -04:00
Evan Miller
0e9c1810f1 Improved support for Access 2010, 2013, and 2016
Some Access 2010 files use 0x03 as the version number rather than
0x0103. For this reason I have changed the call to mdb_get_int32 to
mdb_get_byte.

In addition, according to the Library of Congress page:

https://www.loc.gov/preservation/digital/formats/fdd/fdd000463.shtml

Access 2016 uses 0x05 as the version number. I have inferred from the
Wikipedia page that Access 2013 likely uses 0x04.
2018-03-05 06:39:57 -05:00
Cyber Emissary
40b7818906
Merge pull request #2 from mdjnewman/unknown-version-logging
Print unknown Jet versions in libmdb
2018-02-12 16:43:37 -05:00
Matt Newman
d196436a27 Print unknown Jet versions in libmdb 2018-01-16 18:24:53 -05:00
leecher1337
5c32359f3e Fixed severe double-free bug on mdb_clone_handle with immediate mdb_close() afterwards leading to memory corruption 2017-12-03 17:53:41 +01:00
Vladimir Rutsky
9fb36c0f07 fix typo: "enought" 2015-03-04 13:23:23 +03:00
Nirgal Vourgère
2a70e16a8b Allow CFLGAS="-std=c99 -D_POSIX_C_SOURCE=2"
Use glib function:
strcasecmp -> g_ascii_strcasecmp
bzero -> memset
strdup -> g_strdump

Don't use arithmetic void*+int
2014-12-28 12:36:55 +01:00
Nirgal Vourgère
4a3f3492cd Prints "file not found" when that happens
... rather than the obscure "Can't alloc filename"
2013-07-18 15:21:14 +02:00
Nirgal Vourgère
7841d30d43 Revert use of config.h
Revert
7162e8db74
088493d499

And drop AC_CONFIG_HEADERS so that config goes though the command line.
No longer generating config.h, update .gitignore
2013-07-15 02:42:12 +02:00
Nirgal Vourgère
7162e8db74 Include config.h in all .c files
Need to be the first file since it may define large files support
and other options.
2013-07-04 10:53:13 +02:00
Nirgal Vourgère
365f7959ed Fixed password decoding
Thanks Jimmy Taker compilation warning.
2013-06-27 23:46:46 +02:00
Nirgal Vourgère
851877c86c Changed printf specifier for off_t
Fixes some warnings on OSX
2012-10-04 15:37:30 +02:00
Nirgal Vourgère
b0fb6a4167 Add basic support for Access 2010
Thanks Jakob Egger:
a928a36804
2012-07-07 21:08:25 +02:00
Jean-Michel Vourgère
c566407eaf Experimental support for JET5 .accdb files
Right now, they are handled like JET4 file.
2012-07-03 00:31:23 +02:00
Nirgal Vourgre
dd0f4c3819 Patch docs.diff from Nirgal 2011-08-28 19:53:29 -04:00
Brian Bruns
87af69a15e Debian patch 170-sequences from Nirgal Vourgère 2010-06-20 16:30:47 -04:00
Brian Bruns
4c83570d41 Patch 120-decrypt from David Mansfield 2010-06-17 22:23:45 -04:00
whydoubt
22c3b15218 Use more appropriate types (void *, size_t) 2005-06-28 04:53:37 +00:00
whydoubt
d0474b4692 Remove remaining int24 uses 2005-06-23 07:04:17 +00:00
whydoubt
160418635d Clean up some gcc4 warnings 2005-05-02 12:46:33 +00:00
whydoubt
6587feb47e Fix segfault on file-not-found 2005-03-28 03:33:11 +00:00
whydoubt
30b165938b Replace a few mdb_pg_get_int's with mdb_get_int's 2005-03-22 13:06:57 +00:00
whydoubt
f33a9564d1 Changes for compiling in MSVC (Martin Ellis) 2005-03-13 05:26:38 +00:00
whydoubt
d06cb3e47d Combine functions that bind a column and its length 2004-12-31 01:26:28 +00:00