diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2019-01-27 15:16:15 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-04-26 16:49:25 +0200 |
commit | e049f923924f89cb621abe2ab001d955d97d6020 (patch) | |
tree | 4c7a9c2eccbd84272441ea65934f02892d6dd812 /storage/connect/value.cpp | |
parent | 52eb4f172cc85bf2c9dcc515f747d9bd23089c65 (diff) | |
download | mariadb-git-e049f923924f89cb621abe2ab001d955d97d6020.tar.gz |
Squashed commit of connect/10.0:
commit ac275d0b4ad (connect/10.0)
Author: Olivier Bertrand <bertrandop@gmail.com>
Date: Wed Mar 27 12:46:20 2019 +0100
Comment out unrecognized command line options: Modified CMakeLists.txt
commit 592f1f75ad6
Author: Olivier Bertrand <bertrandop@gmail.com>
Date: Tue Mar 26 19:52:33 2019 +0100
Replace Command not recognized by CMake modified: CMakeLists.txt
commit 00f72199b16
Author: Olivier Bertrand <bertrandop@gmail.com>
Date: Tue Mar 26 18:15:08 2019 +0100
- Fix MDEV-15793: Server crash in PlugCloseFile with sql_mode=''
Fixed by replacing sprinf by snprintf in ShowValue to avoid
buffer overflow. It nows always use a buffer and returns int.
modified: storage/connect/tabdos.cpp
modified: storage/connect/tabfmt.cpp
modified: storage/connect/value.cpp
modified: storage/connect/value.h
- Fix MDEV-18292: CONNECT Engine JDBC not able to issue
simple UPDATE statement from trigger or stored procedure
Was not fixed when the same table was called several times
with different modes. Fixed by checking if a new statement
is compatible in the start_stmt function. It nows do the
same checks than external_lock.
modified: storage/connect/ha_connect.cc
modified: storage/connect/ha_connect.h
- typo
modified: storage/connect/user_connect.cc
- Fix GetTableName that returned wrong value under Windows
modified: storage/connect/ha_connect.cc
- Fix MDEV-13136: enhance CREATE SERVER MyServerName
FOREIGN DATA WRAPPER to work with CONNECT engine
modified: storage/connect/tabjdbc.cpp
- Add a function to retrieve User variable value (DEVELOPMENT only)
modified: storage/connect/ha_connect.cc
modified: storage/connect/jsonudf.cpp
modified: storage/connect/jsonudf.h
modified: storage/connect/tabjdbc.cpp
- Fix MDEV-18192: CONNECT Engine JDBC not able to issue
simple UPDATE statement from trigger or stored procedure
modified: storage/connect/tabext.cpp
modified: storage/connect/tabext.h
modified: storage/connect/tabjdbc.cpp
- Enable CONNECT tables to have triggers
Update version number
modified: storage/connect/ha_connect.cc
- Make user and password defined in CREATE TABLE have precedence on
the ones specified in a Federated Server.
modified: storage/connect/tabjdbc.cpp
- JSONColumns: Copy locally constant strings to fix error in OEM modules
modified: storage/connect/tabjson.cpp
commit 99de7f4e486
Author: Olivier Bertrand <bertrandop@gmail.com>
Date: Sun Jan 27 15:16:15 2019 +0100
- Fix MDEV-18192: CONNECT Engine JDBC not able to issue
simple UPDATE statement from trigger or stored procedure
modified: storage/connect/tabext.cpp
modified: storage/connect/tabext.h
modified: storage/connect/tabjdbc.cpp
- Enable CONNECT tables to have triggers
Update version number
modified: storage/connect/ha_connect.cc
- Make user and password defined in CREATE TABLE have precedence on
the ones specified in a Federated Server.
modified: storage/connect/tabjdbc.cpp
- JSONColumns: Copy locally constant strings to fix error in OEM modules
modified: storage/connect/tabjson.cpp
Diffstat (limited to 'storage/connect/value.cpp')
-rw-r--r-- | storage/connect/value.cpp | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index e159efaa989..d9330a68a15 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -1,7 +1,7 @@ /************* Value C++ Functions Source Code File (.CPP) *************/ -/* Name: VALUE.CPP Version 2.8 */ +/* Name: VALUE.CPP Version 2.9 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2001-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 2001-2019 */ /* */ /* This file contains the VALUE and derived classes family functions. */ /* These classes contain values of different types. They are used so */ @@ -882,18 +882,16 @@ bool TYPVAL<TYPE>::GetBinValue(void *buf, int buflen, bool go) /* TYPVAL ShowValue: get string representation of a typed value. */ /***********************************************************************/ template <class TYPE> -char *TYPVAL<TYPE>::ShowValue(char *buf, int len) +int TYPVAL<TYPE>::ShowValue(char *buf, int len) { - sprintf(buf, Xfmt, len, Tval); - return buf; + return snprintf(buf, len + 1, Xfmt, len, Tval); } // end of ShowValue template <> -char *TYPVAL<double>::ShowValue(char *buf, int len) +int TYPVAL<double>::ShowValue(char *buf, int len) { - // TODO: use snprintf to avoid possible overflow - sprintf(buf, Xfmt, len, Prec, Tval); - return buf; + // TODO: use a more appropriate format to avoid possible truncation + return snprintf(buf, len + 1, Xfmt, len, Prec, Tval); } // end of ShowValue /***********************************************************************/ @@ -1588,10 +1586,17 @@ bool TYPVAL<PSZ>::GetBinValue(void *buf, int buflen, bool go) /***********************************************************************/ /* STRING ShowValue: get string representation of a char value. */ /***********************************************************************/ -char *TYPVAL<PSZ>::ShowValue(char *, int) - { - return Strp; - } // end of ShowValue +int TYPVAL<PSZ>::ShowValue(char *buf, int buflen) +{ + int len = (Null) ? 0 : strlen(Strp); + + if (buf && buf != Strp) { + memset(buf, ' ', buflen + 1); + memcpy(buf, Strp, MY_MIN(len, buflen)); + } // endif buf + + return len; +} // end of ShowValue /***********************************************************************/ /* STRING GetCharString: get string representation of a char value. */ @@ -1800,10 +1805,9 @@ void DECVAL::Reset(void) /***********************************************************************/ /* DECIMAL ShowValue: get string representation right justified. */ /***********************************************************************/ -char *DECVAL::ShowValue(char *buf, int len) +int DECVAL::ShowValue(char *buf, int len) { - sprintf(buf, Xfmt, len, Strp); - return buf; + return snprintf(buf, len + 1, Xfmt, len, Strp); } // end of ShowValue /***********************************************************************/ @@ -1868,14 +1872,13 @@ int DECVAL::CompareValue(PVAL vp) BINVAL::BINVAL(PGLOBAL g, void *p, int cl, int n) : VALUE(TYPE_BIN) { assert(g); -//Len = n; - Len = (g) ? n : (p) ? strlen((char*)p) : 0; + Len = n; Clen = cl; Binp = PlugSubAlloc(g, NULL, Clen + 1); memset(Binp, 0, Clen + 1); if (p) - memcpy(Binp, p, Len); + memcpy(Binp, p, MY_MIN(Len,Clen)); Chrp = NULL; } // end of BINVAL constructor @@ -2264,14 +2267,12 @@ bool BINVAL::GetBinValue(void *buf, int buflen, bool go) /***********************************************************************/ /* BINVAL ShowValue: get string representation of a binary value. */ /***********************************************************************/ -char *BINVAL::ShowValue(char *buf, int len) - { - //int n = MY_MIN(Len, len / 2); - - //sprintf(buf, GetXfmt(), n, Binp); - //return buf; - return (char*)Binp; - } // end of ShowValue +int BINVAL::ShowValue(char *buf, int len) +{ + memset(buf, 0, len + 1); + memcpy(buf, Binp, MY_MIN(len, Len)); + return Len; +} // end of ShowValue /***********************************************************************/ /* BINVAL GetCharString: get string representation of a binary value. */ @@ -2749,43 +2750,33 @@ char *DTVAL::GetCharString(char *p) /***********************************************************************/ /* DTVAL ShowValue: get string representation of a date value. */ /***********************************************************************/ -char *DTVAL::ShowValue(char *buf, int len) - { - if (Pdtp) { - char *p; +int DTVAL::ShowValue(char *buf, int len) +{ + int rv = 0; + if (Pdtp) { if (!Null) { - size_t m, n = 0; + size_t n = 0, m = len + 1; struct tm tm, *ptm = GetGmTime(&tm); - - - - if (Len < len) { - p = buf; - m = len; - } else { - p = Sdate; - m = Len + 1; - } // endif Len if (ptm) - n = strftime(p, m, Pdtp->OutFmt, ptm); + n = strftime(buf, m, Pdtp->OutFmt, ptm); if (!n) { - *p = '\0'; - strncat(p, "Error", m); - } // endif n + *buf = '\0'; + strncat(buf, "Error", m); + rv = 5; + } else + rv = (int)n; - } else { - p = buf; - *p = '\0'; // DEFAULT VALUE ??? - } // endif Null + } else + *buf = '\0'; // DEFAULT VALUE ??? - return p; } else - return TYPVAL<int>::ShowValue(buf, len); + rv = TYPVAL<int>::ShowValue(buf, len); - } // end of ShowValue + return rv; +} // end of ShowValue #if 0 // Not used by CONNECT /***********************************************************************/ |