Commit Graph
100 Commits
Author SHA1 Message Date
Evan Miller ed894ef12c Merge pull request #257 from mjwoodcock/mysql-schema
Mysql schema
2021-02-16 16:48:42 -05:00
Evan Miller 1bfce353d4 Move mdb_col_to_string warning 2021-02-15 21:25:53 -05:00
Evan Miller abe820c66c Version 0.9.2, Beta 5 2021-02-15 19:59:23 -05:00
Evan Miller e655cba907 Fix handling of numeric types in ODBC driver
Fixes #255 and supersedes #256
2021-02-15 19:50:15 -05:00
Evan Miller b9c065885c Merge pull request #254 from h3xx/fix-library-cflags
Add -DHAVE_GLIB to library cflags if needed
2021-02-10 16:11:24 -05:00
Evan Miller c5593d893e Merge pull request #253 from kalpha2/patch-1
Update write.c
2021-02-10 12:45:22 -05:00
Evan Miller 0c34e1aa2b Versio 0.9.2, Beta 4 2021-02-05 14:02:12 -05:00
Evan Miller 763716ecc6 Fix unused function warning without iconv 2021-02-02 18:40:40 -05:00
Evan Miller 77f78ea757 Version 0.9.2, Beta 3 2021-01-29 08:32:49 -05:00
Evan Miller 4e969425ac Add (fake) g_unichar_to_utf8 2021-01-22 07:45:47 -05:00
Evan Miller da80fb3430 Make mdb_iconv_name_from_code_page static 2021-01-21 23:25:46 -05:00
Evan Miller 468502bc87 Terminate string 2021-01-21 23:16:33 -05:00
Evan Miller 0aa3aeee42 Simplify (fake) g_locale_to_utf8
Use mbstowcs and a manual UTF-8 conversion so we don't have to sniff
the locale and require iconv.
2021-01-21 23:08:55 -05:00
Evan Miller f1eac042b5 Fix misuse of "%*s" in sprintf strings
%*s takes the output length, not the input length. The intended
specifier was %.*s in several places. Bug(s) introduced in
2bb31f05ee
2021-01-21 18:27:20 -05:00
Evan Miller 848303f9f0 Version 0.9.2, Beta 2 2021-01-20 09:14:29 -05:00
Evan Miller 9904b079bf Restore the HACKING file with a redirect notice
Several pages link to the old file and we don't want to break those
links.
2021-01-20 09:13:30 -05:00
Evan Miller 70c1b66278 Use correct bind types for SQLBindCol / SQLFetch (#242)
SQLFetch / SQLExtendedFetch now skip the mdb_sql machinery and use
SQLGetData on their bound columns instead. We rely on mdb_fetch_row
to skip to the correct page without any bindings and then SQLGetData will
do the rest.

SQLFetch will now correctly return SQL_SUCCESS_WITH_INFO if one or more
 bound columns have their data truncated, and will return several kinds of errors
(provided by SQLGetData) that were previously ignored.

Updated the unit test with a SQL_C_LONG type for demonstration purposes.

Fixes #23
2021-01-20 09:00:48 -05:00
Evan Miller 615b625d79 Let LC_COLLATE influence string-comparison operations
By default this will be set to the C locale, but set it to the user's
locale when string comparisons are performed from mdb-sql. Note that
this can be overridden with the LC_COLLATE environment variable.

We could infer the collation locale from the file itself, but this will
likely require a big ball of glue between the Windows locales and Unix
ones.
2021-01-19 21:24:31 -05:00
Evan Miller f99c5539e7 Add --version option to the CLI tools
See #232
2021-01-19 20:37:25 -05:00
Evan Miller 9e85bc4153 Clean up backend export logic
* Differentiate character lengths from byte lengths (see #112)

* Use GNU-style indexed initializers for clarity

* Remove needs_quotes since it's not used anywhere
2021-01-19 18:03:10 -05:00
Evan Miller dbc1aa7ea2 Document TOP and LIMIT clauses in the man page 2021-01-19 16:43:10 -05:00
Evan Miller 8c91654426 Man page and usage updates
* MDBOPTS=no_memo is not used anywhere; mark deprecated and print a
  warning if enabled

* Mark MDBOPTS=use_index as experimental in the man pages

* MDBOPTS need to be colon separated

* Document new long forms of mdb-queries options
2021-01-19 16:27:36 -05:00
Evan Miller 0aa88f85d5 Support scale/precision with more column types 2021-01-19 15:55:57 -05:00
Evan Miller aec667a033 Fix numeric scale/precision on Jet3 databases 2021-01-19 15:23:28 -05:00
Evan Miller d089c4072d More locale-awareness for command line arguments 2021-01-18 18:15:30 -05:00
Evan Miller 1e35bddc62 Migrate mdb-queries over to the GLib machinery
This buys us an auto-generated usage string and locale-awareness for the
query name. Short option names are preserved and long names are added.
2021-01-18 17:45:24 -05:00
Evan Miller 8fff5b0ac0 Merge pull request #239 from pedromorgan/apidocs_1
apidocs with doxygen
2021-01-16 11:49:12 -05:00
Evan Miller 52cd0779d6 Version 0.9.2, Beta 1 2021-01-15 08:26:04 -05:00
Evan Miller dd13e20456 More bounds checking 2021-01-15 08:08:51 -05:00
Evan Miller 89e2361582 Fix buffer overrun (oss-fuzz/28832+28807)
len_out was wrapping to a large number when bad input was encountered.
Ensure it's non-zero before proceeding with iconv.
2021-01-15 07:44:50 -05:00
Evan Miller 0e3a627ee6 Make command-line arguments locale-aware (#237)
GLib will automatically convert command line options to UTF-8 provided that setlocale(LC_TYPE, "") is called first, and the argument type is STRING (but not FILENAME). Update the CLI tools to take advantage of this behavior, and likewise implement it in fakeglib.

GLib does not automatically convert non-option arguments (i.e. everything remaining in argv after option processing), so manually call g_locale_to_utf8 on these arguments when they represent table names. This should fix the CLI tools when processing non-ASCII table names in non-UTF-8 locales. Also update fakeglib to implement a fast and loose version of g_locale_to_utf8, and factor out some of the code page => iconv name logic in iconv.c so it can be used in our fake g_locale_to_utf8. This adds a new symbol mdb_iconv_name_from_code_page that is not advertised in the main header file. I did not want to include mdbtools.h from fakeglib.c, but maybe that's not important.
2021-01-14 17:34:50 -05:00
Evan Miller 42431bbba8 Fuzzing workflow (#230)
Add a CIFuzz workflow (and a corresponding badge to the README)
2021-01-14 14:54:37 -05:00
Evan Miller b9531290af GitHub Actions: Pass -e to test scripts
This ensures that the script will exit with an error code if any line of
the script fails
2021-01-13 06:47:25 -05:00
Evan Miller 20842c642a mdb-schema: Exit with code 1 if the requested table is not found 2021-01-12 14:08:25 -05:00
Evan Miller 7893a948ce Fix infinite loop (See oss-fuzz/28789)
A loop is still possible with mutually referencing pages but eliminating
self-references should fix the major timeouts
2021-01-07 21:29:37 -05:00
Evan Miller c0880f0e40 Fix potential realloc() memory leak reading OLE objects
See oss-fuzz/28791
2021-01-07 21:11:12 -05:00
Evan Miller c31daeb2c4 Improved bounds and return value checking (oss-fuzz/29329) 2021-01-07 19:59:45 -05:00
Evan Miller 9b5e591905 Improved bounds checking (fixes oss-fuzz/29328) 2021-01-07 18:46:07 -05:00
Evan Miller 9e883cb100 Version 0.9.1, final 2021-01-03 20:23:38 -05:00
Evan Miller 14af1f82f1 Version 0.9.1, Beta 3 2021-01-01 08:11:29 -05:00
Evan Miller 24a7fdab78 Restore 0.9.0 API backward compatibility of mdb_print_col and MDB_BINEXPORT_*
Other programs (e.g. gmdb2) use mdb_print_col, so restore the old enum
names and values. MDB_EXPORT_ESCAPE_INVISIBLE can be OR'ed into the
last argument to enable C-style escaping of text fields.
2020-12-30 10:28:49 -05:00
Evan Miller d51a37a760 Remove mdb_find_row and row_size warnings
These aren't helpful or actionable, and may not actually indicate any
kind of problem, so remove them.
2020-12-29 15:21:22 -05:00
Evan Miller 6db8ed13a6 Remove zero-row checks #120
Improperly closed databases may set num_rows to zero. Allow reading
of these tables anyway.
2020-12-29 15:10:31 -05:00
Evan Miller 197c3dc35a use_index now requires libmswstr. See #215 and #226
Print a warning if use_index is turned on but libmswstr is not found.  I
suppose we could enable indexes only on JET3 databases, but I am not at
all confident in the JET3 index logic, as it seems to break on non-ASCII
input. So I'd rather just print this warning and require some
hoop-jumping.
2020-12-29 13:13:25 -05:00
Evan Miller 0ad6fb33f6 Merge pull request #222 from evanmiller/merge-108
Revise and merge in #108 (new --escape-invisible flag to mdb-export)
2020-12-29 12:50:04 -05:00
Evan Miller ed6f72252f Version 0.9.1, Beta 2 2020-12-29 10:30:20 -05:00
Evan Miller e6a09b8bd5 Report SQLAllocEnv error in ODBC unit test 2020-12-29 09:25:55 -05:00
Evan Miller aeee354405 Fix infinite loop exporting SQLite schema 2020-12-29 09:24:31 -05:00
Evan Miller 538711e450 Remove unnecessary casts 2020-12-28 22:30:20 -05:00
Evan Miller 658e91c2ae Replace strcpy with g_strdup 2020-12-28 22:29:19 -05:00
Evan Miller c10232fdf1 Use fewer hard-coded sizes 2020-12-28 22:04:06 -05:00
Evan Miller e1e5d9738e Use thread-local storage in ODBC connector
Fix possible race condition with multiple connections in the same
process
2020-12-28 22:01:36 -05:00
Evan Miller 6fae16d5ef Fix status badge link 2020-12-28 21:43:32 -05:00
Evan Miller eb5e6348b7 Fix misleading indentation 2020-12-28 21:08:50 -05:00
Evan Miller 5705d595c8 Replace constant with sizeof() 2020-12-28 21:06:38 -05:00
Evan Miller a0ebd91114 Fix potential stack corruption
A mal-formed catalog could overrun certain stack variables. Move the
variables to the heap and allocate them to hold the active bind size.
2020-12-28 21:02:17 -05:00
Evan Miller d35807cd6c Remove unused variable 2020-12-28 20:22:19 -05:00
Evan Miller 2bb31f05ee Improve bounds checking
No particular crashes, but replace strcpy / strncpy with snprintf
and GLib functions wherever possible.
2020-12-28 20:12:39 -05:00
Evan Miller 31d8bc13aa Fix extra newline in mdb-sql prompt
A newline appeared after "=> " when readline was not found on the
system.
2020-12-28 20:11:06 -05:00
Evan Miller e2c597f669 Update NEWS file for 0.9.1 Beta 1 2020-12-23 15:40:39 -05:00
Evan Miller 6ebe1b89f5 Merge branch 'dev' of github.com:mdbtools/mdbtools into dev 2020-12-23 15:37:18 -05:00
Evan Miller 30a4742d70 Version 0.9.1, Beta 1 2020-12-23 15:36:18 -05:00
Evan Miller 2becb08714 Windows GitHub Action (#231)
* Migrate the Windows Msys2 build from Appveyor to GitHub Actions
* Fix build with newer versions of Msys2 (fix `vasprintf` conflict)
* Enable SQL tests on the Cygwin build on Appveyor
* Fix an error message about Bison not being available when in fact Flex was not available
* Don't fail fast with Mac and Linux GitHub Actions
2020-12-23 09:34:21 -05:00
Evan Miller 76c2ada332 Use scientific notation only for very small numbers
See #84
2020-12-21 17:51:27 -05:00
Evan Miller ccd19c69fa SQLite does not support foreign keys via ALTER TABLE
See #82. A complete solution would add the foreign keys to CREATE TABLE
but the goal here is to stop generating bad SQL.
2020-12-21 17:28:29 -05:00
Evan Miller f6884cdc01 Merge pull request #93 from ewenmcneill/postgres_namespace_fixes
Postgres: No namespace in INDEX, CONSTRAINT names
2020-12-21 17:01:22 -05:00
Evan Miller 307cc50dc0 Fix Appveyor builds 2020-12-21 16:02:30 -05:00
Evan Miller cb0ee059b2 Migrate from Travis CI to GitHub Actions (#229)
* Add GitHub Actions workflow

* Consolidate CI test commands into test_script.sh

* Remove Travis build
2020-12-21 15:42:38 -05:00
Evan Miller 8dd10d332e Merge pull request #228 from evanmiller/no-math
Remove math.h
2020-12-21 15:34:16 -05:00
Evan Miller 25435201b4 Remove math.h 2020-12-21 11:26:45 -05:00
Evan Miller a2f34b1748 Merge pull request #227 from evanmiller/index-lang
Use the language ID from the DB header for indexing
2020-12-21 09:50:09 -05:00
Evan Miller ebb049eb6a Rename --escape-c to --escape-invisible 2020-12-21 09:30:02 -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 ec994b6f43 Merge pull request #225 from evanmiller/gcc-initializers
Use GCC style initializers for MdbFormatConstants
2020-12-20 20:48:38 -05:00
Evan Miller b8ec7a2ec7 Use GCC style initializers for MdbFormatConstants 2020-12-20 20:15:13 -05:00
Evan Miller c6f3b2f858 Merge pull request #224 from evanmiller/jet3-encodings
Simplify header-reading logic and support JET3 code pages
2020-12-20 20:12:06 -05:00
Evan Miller f85905b5c8 Add a simple Latin-1 => UTF-8 transcoder w/o iconv 2020-12-20 19:54:51 -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 a8414720e4 Use wcstombs when iconv is not present (#223)
Replace the jerry-built UTF-16 => Latin-1 code path with a cross-platform wcstombs solution that emits UTF-8.

This adds an element to the end of the MdbHandle struct, but should not break any existing code.

A run-time option could be added later to emit other encodings, but people who care about such things can just use the iconv code path.
2020-12-20 17:56:33 -05:00
Evan Miller 8ed9c142a0 Remove copy-paste fragment 2020-12-19 13:26:19 -05:00
Evan Miller bc97306d64 Merge branch 'master' of github.com:dragonfly-science/mdbtools into merge-108
Merge in pull request #108 with a few changes:

* Use the newer mdb_print_col function

* Redefine the last argument of mdb_print_col to be a flags argument

* Rename and redefine the BINEXPORT enums. While technically public,
  these were never intended as a public API.

* Name the command line option --escape-c
2020-12-19 13:21:32 -05:00
Evan Miller fb6637c503 Fix unused but set variable warning (#221)
Refactor mdb_unicode2ascii to eliminate warnings
2020-12-19 09:37:39 -05:00
Evan Miller 1b96ef4b0d Clarify mdb_unicode2ascii API and fix buffer overrun (#220)
There was some confusion as to whether the destination buffer length
should include space for the null terminator. Some callers of the
function assumed that a terminator would be added beyond the end
of the stated buffer size, while others did not. Make everything
consistent and also fix an overrun when there was insufficient
space for the output in the non-iconv implementation.

As stated in a code comment, a better solution would follow the lead
of libxls and use wcstombs and friends when iconv is not available.
But this gets into the weeds with conversion functions named differently
across platforms. The goal here is to fix the buffer overrun.

See oss-fuzz/28773
2020-12-19 08:24:32 -05:00
Evan Miller 7ce75142e8 Merge pull request #219 from evanmiller/oss-fuzz-28790
Fix integer overflow
2020-12-18 19:51:59 -05:00
Evan Miller 50c9bdfee6 Fix buffer overflow (#218)
See oss-fuzz/28787
2020-12-18 19:42:11 -05:00
Evan Miller 78bbf4250e Merge pull request #217 from evanmiller/oss-fuzz-28780
Fix stack overflow
2020-12-18 16:35:48 -05:00
Evan Miller 3d2d534304 Merge pull request #216 from evanmiller/oss-fuzz-28779
Null-terminate binary strings
2020-12-18 16:33:54 -05:00
Evan Miller 16d249748a Fix integer overflow
See oss-fuzz/28790
2020-12-18 11:22:52 -05:00
Evan Miller 89007cba18 Fix stack overflow
See oss-fuzz/28780
2020-12-18 09:35:12 -05:00
Evan Miller a1cda27a58 Null-terminate binary strings
See oss-fuzz/28779
2020-12-18 09:26:28 -05:00
Evan Miller c46c8b0e4d Version 0.9.0, final 2020-12-17 14:03:05 -05:00
Evan Miller c63a62e365 Update configure.ac
* AM_SILENT_RULES has been around for 9 years so just assume it

* dist-zip adds a ZIP archive step to "make dist"
2020-12-17 11:56:51 -05:00
Evan Miller d70a3977b0 Fix Appveyor link 2020-12-17 11:20:23 -05:00
Evan Miller ed6f6d08e3 Update CI badges to dev branch 2020-12-17 11:05:37 -05:00
Evan Miller e7d5125e2b Fix libmdbsql build on Windows 2020-12-17 11:04:54 -05:00
Evan Miller f6be7a74ef Merge pull request #213 from mdbtools/nirgal-patch-2
Drop obsolete files from .gitignore
2020-12-13 08:38:10 -05:00
Evan Miller b0902d1a51 Restore GLib detection. Fixes #212 2020-12-13 07:43:52 -05:00
Evan Miller 47c933b8c3 Merge branch 'dev' of github.com:mdbtools/mdbtools into dev 2020-12-13 07:36:52 -05:00
Evan Miller a19ea4a859 Merge pull request #211 from mdbtools/nirgal-patch-1
Remove obsolete comment
2020-12-13 07:19:16 -05:00
Evan Miller 924ec93ff1 Version 0.9.0, Beta 8 2020-12-04 10:48:37 -05:00