1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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
This commit is contained in:
Olivier Bertrand
2017-03-06 17:23:56 +01:00
parent b2956b2ab4
commit 92d283c026
38 changed files with 1638 additions and 1476 deletions

View File

@@ -1104,7 +1104,7 @@ static my_bool JsonInit(UDF_INIT *initid, UDF_ARGS *args,
} // endif g
g->Mrr = (args->arg_count && args->args[0]) ? 1 : 0;
g->ActivityStart = (PACTIVITY)more;
g->More = more;
initid->maybe_null = mbn;
initid->max_length = reslen;
initid->ptr = (char*)g;
@@ -1449,7 +1449,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
} // endif b
ml += (unsigned long)g->ActivityStart; // more
ml += g->More;
if (ml > g->Sarea_Size) {
free(g->Sarea);
@@ -2914,7 +2914,6 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *)
{
char *p, *path, *str = NULL;
int rc;
PJSON jsp;
PJSNX jsx;
PJVAL jvp;
@@ -2926,6 +2925,9 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item)
g->N = 1;
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
@@ -2933,11 +2935,12 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
return NULL;
} // endif jump_level
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
str = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) {
@@ -2980,8 +2983,23 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function
g->Activityp = (PACTIVITY)str;
#if defined(USE_TRY)
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
str = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
PUSH_WARNING(g->Message);
str = NULL;
} // end catch
err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
fin:
if (!str) {
@@ -3254,7 +3272,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error)
{
char *p, *path = NULL;
int k, rc;
int k;
PJVAL jvp, jvp2;
PJSON jsp;
PJSNX jsx;
@@ -3274,6 +3292,9 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item)
g->N = 1;
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
@@ -3282,12 +3303,13 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
return NULL;
} // endif jump_level
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, !g->Xchk)) {
@@ -3326,8 +3348,25 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function
g->Activityp = (PACTIVITY)path;
#if defined(USE_TRY)
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
} // end catch
err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (!path) {
*res_length = 0;
@@ -3379,7 +3418,7 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error)
{
char *p, *path = NULL;
int rc, mx = 10;
int mx = 10;
PJVAL jvp, jvp2;
PJSON jsp;
PJSNX jsx;
@@ -3400,6 +3439,9 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else if (initid->const_item)
g->N = 1;
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
@@ -3408,12 +3450,13 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
return NULL;
} // endif jump_level
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true)) {
@@ -3453,8 +3496,25 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function
g->Activityp = (PACTIVITY)path;
#if defined(USE_TRY)
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
} // end catch
err:
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
if (!path) {
*res_length = 0;
@@ -3637,7 +3697,7 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error)
{
char *p, *path, *str = NULL;
int w, rc;
int w;
my_bool b = true;
PJSON jsp;
PJSNX jsx;
@@ -3659,33 +3719,45 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
w = 2;
else {
PUSH_WARNING("Logical error, please contact CONNECT developer");
goto err;
goto fin;
} // endelse
// Save stack and allocation environment and prepare error return
#if defined(USE_TRY)
try {
#else // !USE_TRY
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
goto fin;
} // endif jump_level
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
if (setjmp(g->jumper[++g->jump_level])) {
PUSH_WARNING(g->Message);
str = NULL;
goto err;
} // endif rc
#endif // !USE_TRY
if (!g->Xchk) {
if (CheckMemory(g, initid, args, 1, true, false, true)) {
PUSH_WARNING("CheckMemory error");
#if defined(USE_TRY)
throw 1;
#else // !USE_TRY
goto err;
#endif // !USE_TRY
} else
jvp = MakeValue(g, args, 0);
if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) {
#if defined(USE_TRY)
throw 2;
#else // !USE_TRY
PUSH_WARNING(g->Message);
goto err;
#endif // !USE_TRY
} // endif jsp
} else
@@ -3729,8 +3801,21 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function
g->Activityp = (PACTIVITY)str;
#if defined(USE_TRY)
} catch (int n) {
if (trace)
htrc("Exception %d: %s\n", n, g->Message);
PUSH_WARNING(g->Message);
str = NULL;
} catch (const char *msg) {
strcpy(g->Message, msg);
PUSH_WARNING(g->Message);
str = NULL;
} // end catch
#else // !USE_TRY
err:
g->jump_level--;
#endif // !USE_TRY
fin:
if (!str) {