Commit Graph

180 Commits

Author SHA1 Message Date
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
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
05bee0c69f Remove unnecessary _XOPEN_SOURCE
This was originally intended to expose strptime, which is no longer
(never?) used  by data.c
2021-04-16 13:04:40 -04:00
Evan Miller
ceb65d6ece Conditionally define _XOPEN_SOURCE
Fixes #298
2021-04-13 07:19:19 -04:00
Ulrich Weber
970023c4e6 fix segfault in SQLGetTypeInfo due pyodbc
dont access pages in mdb_fetch_row when pdata is not initialized.

Happens when a client, e.g. pyodbc, queries for an unsupported type,
e.g. SQL_WVARCHAR, temp_table is empty and further access to it will crash.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff70fe3df in mdb_fetch_row (table=0xa74610) at data.c:467
467				rows = mdb_get_int16(

Backtrace:
0  0x00007ffff70fe3df in mdb_fetch_row (table=0xa74610) at data.c:467
1  0x00007ffff77f8746 in SQLFetch (hstmt=0xa70500) at odbc.c:1074
2  0x00007ffff7729b43 in SQLFetch () from /lib/x86_64-linux-gnu/libodbc.so.2
3  0x00007ffff778d545 in GetColumnSize (cnxn=0x7ffff77eb1f0, cnxn=0x7ffff77eb1f0, psize=0x7ffff77bde00, sqltype=-9) at src/cnxninfo.cpp:81
4  CnxnInfo_New (cnxn=0x7ffff77eb1f0) at src/cnxninfo.cpp:145

Signed-off-by: Ulrich Weber <ulrich.weber@gmail.com>
2021-03-24 13:09:48 +00:00
Evan Miller
ad8c80892b Fix compilation error 2021-03-07 14:36:07 -05:00
Evan Miller
46a65b9789 Fix warning when reading binary properties
Also fix some type-size issues in mdb_col_to_string.

See #262
2021-03-07 09:03:39 -05:00
Evan Miller
1bfce353d4 Move mdb_col_to_string warning 2021-02-15 21:25:53 -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
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
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
538711e450 Remove unnecessary casts 2020-12-28 22:30:20 -05:00
Evan Miller
c10232fdf1 Use fewer hard-coded sizes 2020-12-28 22:04:06 -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
25435201b4 Remove math.h 2020-12-21 11:26:45 -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
7ce75142e8
Merge pull request #219 from evanmiller/oss-fuzz-28790
Fix integer overflow
2020-12-18 19:51:59 -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
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
James Woodcock
42996dad65 Send error message to stderr 2020-11-01 12:56:38 +00:00
James Woodcock
de4f5516b7 Handle errors from mdb_bind_column() 2020-10-31 09:46:00 +00:00
James Woodcock
50f1bd4a86 Return column number from mdb_bind_column()
To match the return from mdb_bind_column_by_name().
2020-10-31 09:40:24 +00:00
James Woodcock
a7885f2680 Bounds check mdb_bind_column()
Return -1 to report out of bounds column number.
2020-10-24 13:27:34 +01: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
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
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
7b51824c89 Consolidate / fix UUID formatting 2020-08-19 20:53:35 -04:00
Evan Miller
3c7761f965 Support --disable-glib flag with ODBC driver 2020-08-10 15:58:22 -04:00
Evan Miller
82bbc0cef7 Improved bounds checking 2020-08-09 16:38:25 -04:00
Evan Miller
c93156626c Fix all sign-compare warnings
Also flip on -Wsign-compare in the default configuration
2020-08-09 16:15:20 -04:00
Evan Miller
2e6e88b96f Improve bounds and return-value checking
Fixes a memory leak and a number of buffer overruns
2020-08-06 15:17:04 -04:00
Evan Miller
4682ec0f8a Fix crash 2020-08-06 14:08:30 -04:00
Evan Miller
04b736c9ff Fix indentation warnings 2020-08-05 23:22:08 -04:00
Evan Miller
1d289a65b3 Fix buffer overruns and NULL pointer deferences 2020-08-05 22:35:56 -04:00
Evan Miller
2b84f6c7f5 Fix buffer overflow 2018-09-20 13:02:32 -07:00
Cyber Emissary
104d952cda
Merge pull request #6 from jimmytaker/omaster
Use bigger buffer when reading big blobs to increase performance
2018-02-12 15:48:30 -05:00
Cyber Emissary
fd230f68f2 precision and scale were used other way around. Flipped their usage
in all places
2018-02-06 13:10:56 -05:00
leecher1337
135f452407
Merge branch 'master' into master 2017-12-03 17:02:15 +01:00
Ewen McNeill
8b1db6c08e mdb-export: Add boolean words option (TRUE/FALSE)
Adds "-B" (--boolean-words) option to mdb-export, which will reconfigure
mdb/data.c to export TRUE/FALSE for boolean values instead of 1/0.  The
option is needed to support BOOLEAN fields on PostgreSQL, which will not
implicitly cast bare 1/0 into a BOOLEAN value.  Value literals are the
SQL TRUE/FALSE, and _quoted_ words meaning true/false and _quoted_
'1'/'0'.  With this flag the SQL TRUE/FALSE values are output, which should
work with several SQL databases.

PostgreSQL Reference:

http://www.postgresql.org/docs/current/static/datatype-boolean.html
2016-04-07 08:45:06 +12:00
Jimmytaker
55d57c65cf Use bigger buffer when reading big blobs to increase performance 2015-10-06 20:43:10 +02:00
leecher1337
e2449c11f3 Added strptime function to SQL parser as a feature. This is needed to i.e. be able to query time-fields in DB and to use dates <1.1.1970 and >19.1.2038. All changes should be backwards-compatible to not break existing queries. 2015-08-30 11:23:57 +02:00
Jimmytaker
a5e1ab8a2e Fix not being able to handle blobs > 16 MB. Limit now at 256 MB 2014-12-29 14:54:25 +01: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
Jimmytaker
850d9e169d Fix not being able to handle blobs > 16 MB. Limit now at 256 MB 2014-12-22 20:14:40 +01:00