Commit graph

18 commits

Author SHA1 Message Date
Mikhail Chalov
2ff01e763e Fix insecure use of strcpy, strcat and sprintf in Connect
Old style C functions `strcpy()`, `strcat()` and `sprintf()` are vulnerable to
security issues due to lacking memory boundary checks. Replace these in the
Connect storage engine with safe new and/or custom functions such as
`snprintf()` `safe_strcpy()` and `safe_strcat()`.

With this change FlawFinder and other static security analyzers report 287
fewer findings.

All new code of the whole pull request, including one or several files that are
either new files or modified ones, are contributed under the BSD-new license. I
am contributing on behalf of my employer Amazon Web Services, Inc.
2023-05-12 15:37:00 +01:00
Olivier Bertrand
5f64276fb2 - Fix MDEV-25863 : Replace __WIN__ by _WIN32
modified:   storage/connect/array.cpp
  modified:   storage/connect/blkfil.cpp
  modified:   storage/connect/block.h
  modified:   storage/connect/bson.cpp
  modified:   storage/connect/cmgoconn.cpp
  modified:   storage/connect/colblk.cpp
  modified:   storage/connect/domdoc.cpp
  modified:   storage/connect/filamap.cpp
  modified:   storage/connect/filamdbf.cpp
  modified:   storage/connect/filamfix.cpp
  modified:   storage/connect/filamgz.cpp
  modified:   storage/connect/filamtxt.cpp
  modified:   storage/connect/filamvct.cpp
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filter.cpp
  modified:   storage/connect/filter.h
  modified:   storage/connect/fmdlex.c
  modified:   storage/connect/global.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/javaconn.cpp
  modified:   storage/connect/javaconn.h
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jmgfam.cpp
  modified:   storage/connect/json.cpp
  modified:   storage/connect/macutil.cpp
  modified:   storage/connect/macutil.h
  modified:   storage/connect/maputil.cpp
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/myconn.cpp
  modified:   storage/connect/myconn.h
  modified:   storage/connect/myutil.cpp
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/odbconn.h
  modified:   storage/connect/os.h
  modified:   storage/connect/osutil.c
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/plugutil.cpp
  modified:   storage/connect/rcmsg.c
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/reldef.h
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabext.cpp
  modified:   storage/connect/tabfix.cpp
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabjdbc.cpp
  modified:   storage/connect/tabmac.cpp
  modified:   storage/connect/tabmac.h
  modified:   storage/connect/tabmul.cpp
  modified:   storage/connect/tabmul.h
  modified:   storage/connect/tabmysql.cpp
  modified:   storage/connect/taboccur.cpp
  modified:   storage/connect/tabodbc.cpp
  modified:   storage/connect/tabpivot.cpp
  modified:   storage/connect/tabrest.cpp
  modified:   storage/connect/tabrest.h
  modified:   storage/connect/tabsys.cpp
  modified:   storage/connect/tabtbl.cpp
  modified:   storage/connect/tabutil.cpp
  modified:   storage/connect/tabvct.cpp
  modified:   storage/connect/tabwmi.cpp
  modified:   storage/connect/tabxcl.cpp
  modified:   storage/connect/tabxml.cpp
  modified:   storage/connect/valblk.cpp
  modified:   storage/connect/value.cpp
  modified:   storage/connect/xindex.cpp
  modified:   storage/connect/xindex.h

- Fix Date errors and SSL warnings
  modified:   storage/connect/mysql-test/connect/r/jdbc.result
  modified:   storage/connect/mysql-test/connect/r/jdbc_new.result
  modified:   storage/connect/mysql-test/connect/t/jdbc.test
  modified:   storage/connect/mysql-test/connect/t/jdbc_new.test

- Update java source files
  modified:   storage/connect/Mongo2Interface.java
  modified:   storage/connect/Mongo3Interface.java
  added:      storage/connect/Client2.java
  added:      storage/connect/Client3.java
  added:      storage/connect/TestInsert2.java
  added:      storage/connect/TestInsert3.java
2021-06-08 17:44:43 +02:00
Olivier Bertrand
94e5d7de85 - Add Support of the MongoDB Java Driver.
modified:   storage/connect/CMakeLists.txt
  modified:   storage/connect/JavaWrappers.jar
  modified:   storage/connect/colblk.h
  modified:   storage/connect/filter.cpp
  modified:   storage/connect/filter.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/ha_connect.h
  modified:   storage/connect/jdbccat.h
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h
  modified:   storage/connect/mongofam.cpp
  modified:   storage/connect/mongofam.h
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/mycat.h
  modified:   storage/connect/tabext.h
  modified:   storage/connect/tabjdbc.cpp
  modified:   storage/connect/tabjdbc.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h
  modified:   storage/connect/tabmgo.cpp
  modified:   storage/connect/tabmgo.h
  created:    storage/connect/Mongo2Interface.java
  created:    storage/connect/Mongo3Interface.java
  created:    storage/connect/cmgoconn.cpp
  created:    storage/connect/cmgoconn.h
  created:    storage/connect/javaconn.cpp
  created:    storage/connect/javaconn.h
  created:    storage/connect/jmgfam.cpp
  created:    storage/connect/jmgfam.h
  created:    storage/connect/jmgoconn.cpp
  created:    storage/connect/jmgoconn.h
  created:    storage/connect/mongo.cpp
  created:    storage/connect/mongo.h
  created:    storage/connect/tabjmg.cpp
  created:    storage/connect/tabjmg.h

- tdbp not initialized when catched exception
in CntGetTDB (connect.cc line 188)
  modified:   storage/connect/connect.h

- CheckCleanup should sometimes doing cleanup on pure info
Sometimes MariaDB loops on info to get the size of all tables in a database.
This can sometimes fail by exhausted memory.
CheckCleanup now have a force boolean parameter (defaulting to false)
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/user_connect.cc
  modified:   storage/connect/user_connect.h

Change the copyright of some source files
  modified:   storage/connect/connect.cc
  modified:   storage/connect/connect.h
  modified:   storage/connect/engmsg.h
  modified:   storage/connect/global.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/ha_connect.h
  modified:   storage/connect/msgid.h
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/mycat.h
  modified:   storage/connect/os.h
  modified:   storage/connect/osutil.c
  modified:   storage/connect/osutil.h
  modified:   storage/connect/user_connect.cc
  modified:   storage/connect/user_connect.h
2017-07-02 22:41:11 +02:00
Olivier Bertrand
3e36eb230b Fix gcc compiler warnings reported by Sergei
modified:   storage/connect/array.cpp
  modified:   storage/connect/array.h
  modified:   storage/connect/blkfil.cpp
  modified:   storage/connect/blkfil.h
  modified:   storage/connect/block.h
  modified:   storage/connect/colblk.cpp
  modified:   storage/connect/colblk.h
  modified:   storage/connect/csort.h
  modified:   storage/connect/filamvct.cpp
  modified:   storage/connect/filter.cpp
  modified:   storage/connect/filter.h
  modified:   storage/connect/global.h
  modified:   storage/connect/json.h
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/tabcol.cpp
  modified:   storage/connect/tabcol.h
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/table.cpp
  modified:   storage/connect/tabodbc.cpp
  modified:   storage/connect/tabodbc.h
  modified:   storage/connect/tabsys.h
  modified:   storage/connect/tabxml.h
  modified:   storage/connect/value.cpp
  modified:   storage/connect/value.h
  modified:   storage/connect/xindex.cpp
  modified:   storage/connect/xindex.h
  modified:   storage/connect/xobject.cpp
  modified:   storage/connect/xobject.h
  modified:   storage/connect/xtable.h

Set values as nullable when retrieving catalog info
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/mysql-test/connect/r/odbc_oracle.result
  modified:   storage/connect/odbconn.cpp

Change format of Jpath
  modified:   storage/connect/json.cpp
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/mysql-test/connect/r/json.result
  modified:   storage/connect/mysql-test/connect/r/json_udf.result
  modified:   storage/connect/mysql-test/connect/r/json_udf_bin.result
  modified:   storage/connect/mysql-test/connect/r/zip.result
  modified:   storage/connect/mysql-test/connect/t/json.test
  modified:   storage/connect/mysql-test/connect/t/json_udf.test
  modified:   storage/connect/mysql-test/connect/t/json_udf_bin.test
  modified:   storage/connect/mysql-test/connect/t/zip.test
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h
  modified:   storage/connect/tabmgo.cpp

Change null representation from ??? to <null>
  modified:   storage/connect/json.cpp

Change the name of UDF that are equal to a native JSON function name
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h
  modified:   storage/connect/mysql-test/connect/t/json_udf.inc
  modified:   storage/connect/mysql-test/connect/t/json_udf2.inc

Fix bug in making JSON project info
  modified:   storage/connect/mongofam.cpp

Fix COMPUTE when one argument is null
  modified:   storage/connect/value.cpp

Value is null only when nullable
  modified:   storage/connect/value.h
2017-05-23 19:35:50 +02:00
Olivier Bertrand
b6a56370d6 Change all preprocessor compiler directives to use __WIN__ as the mean of
specifying Windows or not Windows compile. This is what MariaDB does.
  modified:   storage/connect/array.cpp
  modified:   storage/connect/blkfil.cpp
  modified:   storage/connect/block.h
  modified:   storage/connect/colblk.cpp
  modified:   storage/connect/domdoc.cpp
  modified:   storage/connect/filamap.cpp
  modified:   storage/connect/filamdbf.cpp
  modified:   storage/connect/filamfix.cpp
  modified:   storage/connect/filamtxt.cpp
  modified:   storage/connect/filamvct.cpp
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filter.cpp
  modified:   storage/connect/filter.h
  modified:   storage/connect/fmdlex.c
  modified:   storage/connect/global.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/json.cpp
  modified:   storage/connect/macutil.cpp
  modified:   storage/connect/macutil.h
  modified:   storage/connect/maputil.cpp
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/myconn.cpp
  modified:   storage/connect/myconn.h
  modified:   storage/connect/myutil.cpp
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/odbconn.h
  modified:   storage/connect/os.h
  modified:   storage/connect/osutil.c
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/plugutil.c
  modified:   storage/connect/rcmsg.c
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/reldef.h
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabfix.cpp
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabmac.cpp
  modified:   storage/connect/tabmac.h
  modified:   storage/connect/tabmul.cpp
  modified:   storage/connect/tabmul.h
  modified:   storage/connect/tabmysql.cpp
  modified:   storage/connect/taboccur.cpp
  modified:   storage/connect/tabodbc.cpp
  modified:   storage/connect/tabpivot.cpp
  modified:   storage/connect/tabsys.cpp
  modified:   storage/connect/tabtbl.cpp
  modified:   storage/connect/tabutil.cpp
  modified:   storage/connect/tabvct.cpp
  modified:   storage/connect/tabwmi.cpp
  modified:   storage/connect/tabxcl.cpp
  modified:   storage/connect/tabxml.cpp
  modified:   storage/connect/valblk.cpp
  modified:   storage/connect/value.cpp
  modified:   storage/connect/xindex.cpp
  modified:   storage/connect/xindex.h
2015-05-27 16:23:38 +02:00
Olivier Bertrand
b1ae834165 - Fix using ~ in file name on Linux
modified:
  storage/connect/osutil.c
  storage/connect/plugutil.c
  
- Fix using fmt uninitialized in Tabcolumns
modified:
  storage/connect/tabutil.cpp

- Suppress gcc warning
modified:
  storage/connect/ha_connect.cc
2014-03-31 01:20:35 +02:00
Olivier Bertrand
fe3cbcdffa - Add system variables type_conv and conv_size. This addresses the eventual
conversion from TEXT to VARCHAR  in PROXY and MYSQL tables.
modified:
  storage/connect/ha_connect.cc
  storage/connect/myconn.cpp
  storage/connect/myconn.h
  storage/connect/myutil.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabutil.cpp

- Add the xmap system variable addressing whether file mapping should be used
  to handle indexing.
modified:
  storage/connect/CMakeLists.txt
  storage/connect/ha_connect.cc
  storage/connect/xindex.cpp
  storage/connect/xindex.h

- Do take care of ~ in Linux version of _fullpath (not tested yet)
modified:
  storage/connect/osutil.c
2014-03-30 22:52:54 +02:00
Sergei Golubchik
5c5834b091 *never* put anything with side-effects in an assert() -
asserts can be conditionally compiled out.
2014-03-29 17:31:08 +01:00
Olivier Bertrand
6b63c5b247 - FIX PIVOT bug MDEV-5869 caused by using fop (field option ptr) when NULL.
modified:
  storage/connect/ha_connect.cc

- Suppress the use of connect.in by adding the connect_xtrace system variable.
modified:
  storage/connect/ha_connect.cc

- Make column length, varchar, and temporal column types recognized in discovery
  when using SRCDEF,or PIVOT.
modified:
  storage/connect/ha_connect.cc
  storage/connect/myconn.cpp
  storage/connect/myutil.cpp
  storage/connect/plgdbsem.h

- Avoid (rare) crash when using DECIMAL type. (buf was too small)
modified:
  storage/connect/tabfmt.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabpivot.cpp
  storage/connect/valblk.cpp
  storage/connect/value.cpp

- General cleaning of unused code, standardize tracing, and update version number
modified:
  storage/connect/block.h
  storage/connect/colblk.cpp
  storage/connect/connect.cc
  storage/connect/csort.h
  storage/connect/filamap.cpp
  storage/connect/filamdbf.cpp
  storage/connect/filamfix.cpp
  storage/connect/filamzip.cpp
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/myconn.cpp
  storage/connect/mysql-test/connect/r/alter.result
  storage/connect/mysql-test/connect/r/xml.result
  storage/connect/myutil.cpp
  storage/connect/osutil.c
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
  storage/connect/plugutil.c
  storage/connect/reldef.cpp
  storage/connect/tabcol.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabpivot.cpp
  storage/connect/tabvct.cpp
  storage/connect/user_connect.cc
  storage/connect/valblk.cpp
  storage/connect/value.cpp
  storage/connect/xindex.cpp
2014-03-18 19:25:50 +01:00
Michael Widenius
4712fb14b9 Fixed compiler warnings 2013-08-21 18:20:22 +03:00
Olivier Bertrand
b3ad9a97e9 - Suppress some ubuntu compiler warnings
modified:
  storage/connect/connect.cc
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/odbconn.cpp
  storage/connect/osutil.c
  storage/connect/tabutil.cpp
2013-07-08 19:03:15 +02:00
Alexander Barkov
269fd01bc1 fixing warnings:
- no previous declaration for ‘_isatty’
- implicit declaration of function ‘_isatty’

modified:
  storage/connect/fmdlex.c
  storage/connect/osutil.c
2013-07-08 10:46:15 +04:00
Alexander Barkov
e2461d47cb Fixing the "no previous declaration for ‘_strerror'" warning.
modified:
  storage/connect/filamvct.cpp
  storage/connect/osutil.c
  storage/connect/tabvct.cpp
2013-07-08 10:37:09 +04:00
Alexander Barkov
54f3292831 Fixing warnings (mostly "no previous declaration")
modified:
  storage/connect/ha_connect.cc
  storage/connect/maputil.h
  storage/connect/odbconn.cpp
  storage/connect/osutil.c
  storage/connect/osutil.h
  storage/connect/tabmysql.cpp
  storage/connect/tabutil.cpp
  storage/connect/tabutil.h
2013-05-13 16:48:03 +04:00
Alexander Barkov
f8f79d9334 Fixing wrong sprintf() calls.
modified:
  storage/connect/filamap.cpp
  storage/connect/filamdbf.cpp
  storage/connect/filamfix.cpp
  storage/connect/filamtxt.cpp
  storage/connect/filamvct.cpp
  storage/connect/ha_connect.cc
  storage/connect/osutil.c
  storage/connect/plgdbutl.cpp
  storage/connect/plugutil.c
  storage/connect/tabfix.cpp
  storage/connect/tabxml.cpp
  storage/connect/user_connect.cc
  storage/connect/value.cpp
  storage/connect/xindex.cpp
2013-02-07 17:56:48 +04:00
Alexander Barkov
8cfa84ca87 Fixing compilation warnings:
Using "bool" in pure C code is not a good idea.
- Defining BOOL as "long" on Unix (this is how MS defines it)
- Replacing bool to BOOL in pure C code.

modified:
  storage/connect/global.h
  storage/connect/inihandl.c
  storage/connect/os.h
  storage/connect/osutil.c
  storage/connect/osutil.h
2013-02-07 15:21:56 +04:00
Alexander Barkov
30c4b0ebc2 - Fixing TAB to 2 spaces
- Fixing line endings from "\r\n" to "\n"
2013-02-07 13:34:27 +04:00
Alexander Barkov
d7143a4160 Adding the CONNECT storage engine sources. 2013-01-18 19:21:44 +04:00