Commit Graph

972 Commits

Author SHA1 Message Date
Jan Langer
22af793623 Changed mapping of MDB_DOUBLE for MySQL from float to double 2022-03-08 19:18:08 +01:00
Hans de Goede
03391fc913 Always check mdb_read_table() return value
A couple of places were missing NULL return value checks for
mdb_read_table()'s return value. Add these.

This fixes a NULL pointer deref while running ./test_script.sh
on the test mdb file from oss-fuzz/35972 .

Note this does NOT fix the original problem reported in oss-fuzz/35972
which reports a "Dynamic-stack-buffer-overflow WRITE 16" issue,
which I've been unable to reproduce.
2022-01-25 16:35:28 +01:00
Hans de Goede
4febc7b5c6 Fix null-ptr deref when table->map_sz is 0
The oss-fuzz/36187 attached
clusterfuzz-testcase-minimized-fuzz_mdb-4756071066501120
has a table with a map_sz of 0 and the g_memdup2 call returns NULL for
this, while mdb_map_find_next unconditionally derefs table->usage_map
to read the first byte which contains the map-type.

This leads to a NULL-ptr deref (at least with -fsanitize=address builds),
fix this by rejecting tables with a map_sz of 0.

Note this does NOT fix the original problem reported in oss-fuzz/36187
which reports a "Dynamic-stack-buffer-overflow WRITE 16" issue, which
I've been unable to reproduce.
2022-01-25 15:10:38 +01:00
Christian Ehrhardt
22c379a611 Fix gcc-11 error "directive argument is null"
mdbtools triggered
In function ‘printf’,
    inlined from ‘mdb_dump_catalog’ at catalog.c:195:4:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:112:10:
error: ‘%-12s’ directive argument is null [-Werror=format-overflow=]
  112 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());

This is due to mdb_get_objtype_string potentially returning NULL
which isn't allowed anymore as it would cause a segfault on the latter
print.

Fixes: #352

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2021-09-30 08:19:53 -04:00
Evan Miller
5ddad8660b Clarify some bit-shifting casts 2021-09-29 09:20:24 -04:00
Evan Miller
6de0227a36 Fix export of byte field values >127
Regression introduced in v0.9.3-beta1. Fixes #350
2021-09-29 09:16:22 -04:00
Evan Miller
77ee311eec Rearrange some ODBC code
Move unixODBC specific code to its own source file, and support old
iODBC installations that have only iodbinst.h.
2021-09-08 11:07:17 -04:00
Evan Miller
c04a3fb9a7 Merge branch 'dev' of github.com:mdbtools/mdbtools into dev 2021-09-08 10:58:30 -04:00
Evan Miller
ee5834d239 Print deprecation warnings before usage info 2021-09-08 10:50:28 -04:00
Evan Miller
f0d435ecdb Use TLS macro for cross-platform thread-local storage 2021-09-08 09:09:03 -04:00
Evan Miller
c137d64d13 Improved bounds checking 2021-09-08 06:41:58 -04:00
Evan Miller
4369721363 ODBC: Support SQL_C_WCHAR target type. Fixes #347
Also remove SQLFetchW and SQLGetDataW since they are not documented
in any other ODBC drivers.
2021-09-08 06:15:59 -04:00
Evan Miller
a0e72c5dfa Implement SQLFetchW
Fixes #347
2021-09-06 15:09:46 -04:00
Evan Miller
16b2970931
Merge pull request #344 from nyalldawson/repid_odbc_str2
Customizable UUID format with mdb_uuid_to_string_fmt()
2021-08-30 09:17:25 -04:00
Nyall Dawson
98ef4a1663 [odbc] Ensure repid field formatting matching Microsoft Access ODBC
driver formatting of these fields (i.e. without surrounding {} braces)
2021-08-30 09:34:29 +10:00
Evan Miller
92dc91bfe8
Merge pull request #343 from nyalldawson/fix_index_read_errors
Fix accidental reads of non-index data as indices
2021-08-29 07:20:27 -04:00
Nyall Dawson
d94796d79b Fix accidental reads of non-index data as indices
Follow up be2a287f5c - it's hard to be sure from the commit message,
but I suspect the intention here was to reduce the number of indices
read in that particular situation, instead of allowing replacing
the number of real indices read direct from the table definition
with a larger number.

In any case, omitting a possible index definition which exists
is a safer approach then trying to read an index from non-index data.

Fixes #335
2021-08-29 16:22:34 +10:00
Nyall Dawson
dccc88b722 Fix incorrect conversion of double values
Fixes #339
2021-08-29 15:31:00 +10:00
Nyall Dawson
4c61f2d49b Handle sql queries where a double constant value has a trailing .
with no extra digits, e.g. "my_double_col" = 123.
2021-08-26 23:54:06 -04:00
Nyall Dawson
036f9b95c6 Handle sql queries where a double column is compared to an int
eg "my_double_column" = 123
2021-08-26 23:54:06 -04:00
Nyall Dawson
f4ca6b9e57 Handle sql queries where an integer column is compared to a double value
(e.g. "my_int_column" = 123.0)
2021-08-26 23:54:06 -04:00
Nyall Dawson
f557e6525b Better error output 2021-08-26 23:49:11 -04:00
Nyall Dawson
fa336fd325 Handle sql queries using REP_ID columns 2021-08-26 20:17:39 -04:00
Evan Miller
41d2a797ab Check for mbstowcs_l separately 2021-08-24 15:15:34 -04:00
Evan Miller
0164b4df1a Move Unicode ODBC functions to separate file (remove ODBC's iconv)
Use wcstombs and friends to perform Unicode conversion inside the ODBC
driver. Functionality should be identical as before, except that
installations without iconv will now be able to compile and install the
Unicode (libmdbodbcW) driver.

iconv remains present in the main libmdb library.
2021-08-23 13:39:39 -04:00
Evan Miller
d3eea5f38e Simplify some locale_t code 2021-08-22 12:20:13 -04:00
Evan Miller
d1369407c5 --disable-iconv configure option 2021-08-22 11:36:31 -04:00
Nyall Dawson
fadd536e2e
Add support for <> SQL operator (#329) 2021-08-22 00:28:29 -04:00
Evan Miller
49ee8272ab Remove _GNU_SOURCE (rely on AC_USE_SYSTEM_EXTENSIONS) 2021-08-20 08:23:24 -04:00
Evan Miller
f71924dab6 Use AC_USE_SYSTEM_EXTENSIONS
Defining _XOPEN_SOURCE explicitly in the source file leads to all kinds
of cross-platform headaches, plus incompatibilities between
configure-time capabilities and compile-time features. Let autoconf sort
out how to expose the largest number of functions in a way that is
consistent between configuration and compilation.
2021-08-20 08:06:19 -04:00
Evan Miller
89c7aa27b4 Fix create/drop incorrect argument order
Fixes #328
2021-08-20 08:03:44 -04:00
Nyall Dawson
05d1b373d5
[odbc] Format boolean values correctly as SQL_C_CHAR (#327)
When a boolean column value is requested as a SQL_C_CHAR value,
correctly return a "1" or "0" string value
2021-08-19 21:21:46 -04:00
Evan Miller
7fb7660b09 Restore previous mdb_register_backend API
Add new mdbi_register_backend2 function with the features introduced in
PRs #321 and #322. The purpose is to prevent API/ABI breakage in the
1.0 release.
2021-08-19 06:23:16 -04:00
Nyall Dawson
cfbca2af03
Copy date formats when cloning handle (#326)
Fix date format for odbc handles get reset to default date format
for backend when handle is cloned
2021-08-18 22:08:07 -04:00
Evan Miller
4143f34706 Install ODBC drivers to odbc/ subdirectory
See #315
2021-08-04 16:29:31 -04:00
Evan Miller
d5a42d9fed Bump _XOPEN_SOURCE to 700
This allows locale_t to be defined on Linux.
2021-08-04 16:06:47 -04:00
Evan Miller
c866b04b74 Fix Linux build 2021-08-04 15:59:17 -04:00
Evan Miller
a803abe1cf Change #if to #ifdef in a couple places 2021-08-04 15:55:20 -04:00
Evan Miller
12a888988d Update README and deprecate mdb-hexdump 2021-08-04 15:33:43 -04:00
Evan Miller
a44a8ed8ae
Postgres-style ILIKE operator (with Unicode support) (#244)
Access's `LIKE` is actually case-insensitive, but to prevent breaking existing
programs that rely on mdbtools' case-sensitive behavior, introduce a new
`ILIKE` operator to perform a case-insensitive match. Use GLib's `g_utf8_casefold`
to make the comparison UTF-8 aware. A "poor man's" version is implemented
in fakeglib, which relies on `towlower`, and won't work with multi-grapheme
case transformations (e.g. German Eszett).

Fixes #233
2021-08-04 14:45:31 -04:00
Evan Miller
1b147b8d29
Merge pull request #276 from mdbtools/no-sql
Don't build/install mdb-sql if SQL is not supported
2021-08-04 14:12:20 -04:00
Jose Hernandez
4b5ff01a59 Corrected the name of generated PostgreSQL boolean data type (https://www.postgresql.org/docs/13/datatype-boolean.html) 2021-08-01 18:00:28 +01:00
Jose Hernandez
f7b13bd4a7 Changed the definition of gssize and fixed some memory leaks following code review. 2021-08-01 17:49:21 +01:00
Jose Hernandez
afc6f4888b Added support for name normalisation when generating code for PostgreSQL so that generated artefact names are consistently exported in lowercase. 2021-08-01 15:26:40 +01:00
Jose Hernandez
cec507b967 Introduced customised "create table" DDL statements per database type and made table creation statement in PostgreSQL idempotent so that the DDL generated by mdbtools works nicely with database versioning tools such as flyway or liquibase. 2021-07-31 13:34:08 +01:00
Evan Miller
8692586205 Merge branch 'dev' into no-sql 2021-07-24 11:34:25 -04:00
Evan Miller
f79f942d1f Fix RC4 decryption on big-endian platforms 2021-07-17 10:13:24 -04:00
Evan Miller
45779d03ff
Merge pull request #319 from Bob620/dev
sql: Properly handle arbitrary parentheses placements in PATH breaking SELECT functions
2021-07-14 12:41:59 -04:00
Evan Miller
fe77bc5c8e Remove uses of ntohl 2021-07-14 09:33:24 -04:00
bob620
cf0f5f249c sql: fix arbitrary path parentheses placement interfering with functions 2021-07-13 16:25:32 -05:00