summaryrefslogtreecommitdiff
path: root/storage/connect/value.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2017-03-06 17:23:56 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2017-03-06 17:23:56 +0100
commit92d283c026b66ae772b4343f366f0da6321daa28 (patch)
treeb879196bfea2c540048f26c6c1b4b7bd1c5ac521 /storage/connect/value.cpp
parentb2956b2ab437403f413b65f6fdaaf706847bc833 (diff)
downloadmariadb-git-92d283c026b66ae772b4343f366f0da6321daa28.tar.gz
Fix MDEV-12142 crash when creating CSV table
Was an unprepared longjmp (now throw) Also fix a wrong calculation of To_Line sometimes causing a crash because of buffer overflow. modified: storage/connect/tabdos.cpp Fix a wrong setting of USER for JDBC tables in connect_assisted_discovery. Update jdbc_new.test after that fix, which changed errors. modified: storage/connect/ha_connect.cc modified: storage/connect/mysql-test/connect/r/jdbc_new.result modified: storage/connect/mysql-test/connect/t/jdbc_new.test Make using try/catch/throw the default option modified: storage/connect/CMakeLists.txt Typo modified: storage/connect/xindex.cpp Replace setjmp-longjmp's by try_catch-throw modified: storage/connect/CMakeLists.txt modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filter.cpp modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/osutil.c modified: storage/connect/plgdbutl.cpp deleted: storage/connect/plugutil.c added: storage/connect/plugutil.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabvir.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xobject.cpp
Diffstat (limited to 'storage/connect/value.cpp')
-rw-r--r--storage/connect/value.cpp73
1 files changed, 56 insertions, 17 deletions
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index ced690e77c0..fec38217b0b 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.6 */
+/* Name: VALUE.CPP Version 2.7 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2001-2016 */
+/* (C) Copyright to the author Olivier BERTRAND 2001-2017 */
/* */
/* This file contains the VALUE and derived classes family functions. */
/* These classes contain values of different types. They are used so */
@@ -57,10 +57,17 @@
/* Check macro's. */
/***********************************************************************/
#if defined(_DEBUG)
+#if defined(USE_TRY)
#define CheckType(V) if (Type != V->GetType()) { \
PGLOBAL& g = Global; \
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
- longjmp(g->jumper[g->jump_level], Type); }
+ throw Type;
+#else // !USE_TRY
+#define CheckType(V) if (Type != V->GetType()) { \
+ PGLOBAL& g = Global; \
+ strcpy(g->Message, MSG(VALTYPE_NOMATCH)); \
+ longjmp(g->jumper[g->jump_level], Type);
+#endif // !USE_TRY
#else
#define CheckType(V)
#endif
@@ -1019,12 +1026,20 @@ TYPE TYPVAL<TYPE>::SafeAdd(TYPE n1, TYPE n2)
if ((n2 > 0) && (n < n1)) {
// Overflow
strcpy(g->Message, MSG(FIX_OVFLW_ADD));
- longjmp(g->jumper[g->jump_level], 138);
- } else if ((n2 < 0) && (n > n1)) {
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+ longjmp(g->jumper[g->jump_level], 138);
+#endif // !USE_TRY
+ } else if ((n2 < 0) && (n > n1)) {
// Underflow
strcpy(g->Message, MSG(FIX_UNFLW_ADD));
- longjmp(g->jumper[g->jump_level], 138);
- } // endif's n2
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+ longjmp(g->jumper[g->jump_level], 138);
+#endif // !USE_TRY
+ } // endif's n2
return n;
} // end of SafeAdd
@@ -1047,12 +1062,20 @@ TYPE TYPVAL<TYPE>::SafeMult(TYPE n1, TYPE n2)
if (n > MinMaxVal(true)) {
// Overflow
strcpy(g->Message, MSG(FIX_OVFLW_TIMES));
- longjmp(g->jumper[g->jump_level], 138);
- } else if (n < MinMaxVal(false)) {
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+ longjmp(g->jumper[g->jump_level], 138);
+#endif // !USE_TRY
+ } else if (n < MinMaxVal(false)) {
// Underflow
strcpy(g->Message, MSG(FIX_UNFLW_TIMES));
- longjmp(g->jumper[g->jump_level], 138);
- } // endif's n2
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+ longjmp(g->jumper[g->jump_level], 138);
+#endif // !USE_TRY
+ } // endif's n2
return (TYPE)n;
} // end of SafeMult
@@ -1432,8 +1455,16 @@ void TYPVAL<PSZ>::SetValue(int n)
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
- longjmp(g->jumper[g->jump_level], 138);
- } else
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+ longjmp(g->jumper[g->jump_level], 138);
+#endif // !USE_TRY
+#endif // !USE_TRY
+ } else
SetValue_psz(buf);
Null = false;
@@ -1486,8 +1517,12 @@ void TYPVAL<PSZ>::SetValue(longlong n)
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
- longjmp(g->jumper[g->jump_level], 138);
- } else
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+ longjmp(g->jumper[g->jump_level], 138);
+#endif // !USE_TRY
+ } else
SetValue_psz(buf);
Null = false;
@@ -1529,8 +1564,12 @@ void TYPVAL<PSZ>::SetValue(double f)
if (k > Len) {
sprintf(g->Message, MSG(VALSTR_TOO_LONG), buf, Len);
- longjmp(g->jumper[g->jump_level], 138);
- } else
+#if defined(USE_TRY)
+ throw 138;
+#else // !USE_TRY
+ longjmp(g->jumper[g->jump_level], 138);
+#endif // !USE_TRY
+ } else
SetValue_psz(buf);
Null = false;