summaryrefslogtreecommitdiff
path: root/storage/connect
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2021-02-03 15:35:32 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2021-02-05 10:56:05 +0100
commitc04ae0d365f4e65bf6c0ccc01c25d597e269d47e (patch)
tree0b023fd5b15bc58e9aac57c8131c4d325d1612db /storage/connect
parent87bf594bc505cef0cc5c3aa436bb134cc8810e86 (diff)
downloadmariadb-git-c04ae0d365f4e65bf6c0ccc01c25d597e269d47e.tar.gz
Fix of crashes of connect engine.
Use size_t everywhere and remove suspicious expression.
Diffstat (limited to 'storage/connect')
-rw-r--r--storage/connect/bson.cpp32
-rw-r--r--storage/connect/bson.h14
-rw-r--r--storage/connect/bsonudf.cpp2
3 files changed, 24 insertions, 24 deletions
diff --git a/storage/connect/bson.cpp b/storage/connect/bson.cpp
index 7665d8520ab..3c33551cb68 100644
--- a/storage/connect/bson.cpp
+++ b/storage/connect/bson.cpp
@@ -82,7 +82,7 @@ BDOC::BDOC(PGLOBAL G) : BJSON(G, NULL)
/***********************************************************************/
PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng)
{
- int i;
+ size_t i;
bool b = false, ptyp = (bool *)pty;
PBVAL bvp = NULL;
@@ -185,7 +185,7 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng)
/***********************************************************************/
/* Parse several items as being in an array. */
/***********************************************************************/
-OFFSET BDOC::ParseAsArray(int& i) {
+OFFSET BDOC::ParseAsArray(size_t& i) {
if (pty[0] && (!pretty || pretty > 2)) {
OFFSET jsp;
@@ -202,7 +202,7 @@ OFFSET BDOC::ParseAsArray(int& i) {
/***********************************************************************/
/* Parse a JSON Array. */
/***********************************************************************/
-OFFSET BDOC::ParseArray(int& i)
+OFFSET BDOC::ParseArray(size_t& i)
{
int level = 0;
bool b = (!i);
@@ -214,7 +214,7 @@ OFFSET BDOC::ParseArray(int& i)
switch (s[i]) {
case ',':
if (level < 2) {
- sprintf(G->Message, "Unexpected ',' near %.*s", ARGS);
+ sprintf(G->Message, "Unexpected ',' near %.*s", (int) ARGS);
throw 1;
} else
level = 1;
@@ -222,7 +222,7 @@ OFFSET BDOC::ParseArray(int& i)
break;
case ']':
if (level == 1) {
- sprintf(G->Message, "Unexpected ',]' near %.*s", ARGS);
+ sprintf(G->Message, "Unexpected ',]' near %.*s", (int) ARGS);
throw 1;
} // endif level
@@ -236,7 +236,7 @@ OFFSET BDOC::ParseArray(int& i)
break;
default:
if (level == 2) {
- sprintf(G->Message, "Unexpected value near %.*s", ARGS);
+ sprintf(G->Message, "Unexpected value near %.*s", (int) ARGS);
throw 1;
} else if (lastvlp) {
vlp = ParseValue(i, NewVal());
@@ -260,7 +260,7 @@ OFFSET BDOC::ParseArray(int& i)
/***********************************************************************/
/* Parse a JSON Object. */
/***********************************************************************/
-OFFSET BDOC::ParseObject(int& i)
+OFFSET BDOC::ParseObject(size_t& i)
{
OFFSET key;
int level = 0;
@@ -283,7 +283,7 @@ OFFSET BDOC::ParseObject(int& i)
level = 2;
} else {
- sprintf(G->Message, "misplaced string near %.*s", ARGS);
+ sprintf(G->Message, "misplaced string near %.*s", (int) ARGS);
throw 2;
} // endif level
@@ -293,14 +293,14 @@ OFFSET BDOC::ParseObject(int& i)
ParseValue(++i, GetVlp(lastbpp));
level = 3;
} else {
- sprintf(G->Message, "Unexpected ':' near %.*s", ARGS);
+ sprintf(G->Message, "Unexpected ':' near %.*s", (int) ARGS);
throw 2;
} // endif level
break;
case ',':
if (level < 3) {
- sprintf(G->Message, "Unexpected ',' near %.*s", ARGS);
+ sprintf(G->Message, "Unexpected ',' near %.*s", (int) ARGS);
throw 2;
} else
level = 1;
@@ -308,7 +308,7 @@ OFFSET BDOC::ParseObject(int& i)
break;
case '}':
if (!(level == 0 || level == 3)) {
- sprintf(G->Message, "Unexpected '}' near %.*s", ARGS);
+ sprintf(G->Message, "Unexpected '}' near %.*s", (int) ARGS);
throw 2;
} // endif level
@@ -321,7 +321,7 @@ OFFSET BDOC::ParseObject(int& i)
break;
default:
sprintf(G->Message, "Unexpected character '%c' near %.*s",
- s[i], ARGS);
+ s[i], (int) ARGS);
throw 2;
}; // endswitch s[i]
@@ -332,7 +332,7 @@ OFFSET BDOC::ParseObject(int& i)
/***********************************************************************/
/* Parse a JSON Value. */
/***********************************************************************/
-PBVAL BDOC::ParseValue(int& i, PBVAL bvp)
+PBVAL BDOC::ParseValue(size_t& i, PBVAL bvp)
{
for (; i < len; i++)
switch (s[i]) {
@@ -398,14 +398,14 @@ suite:
return bvp;
err:
- sprintf(G->Message, "Unexpected character '%c' near %.*s", s[i], ARGS);
+ sprintf(G->Message, "Unexpected character '%c' near %.*s", s[i], (int) ARGS);
throw 3;
} // end of ParseValue
/***********************************************************************/
/* Unescape and parse a JSON string. */
/***********************************************************************/
-OFFSET BDOC::ParseString(int& i)
+OFFSET BDOC::ParseString(size_t& i)
{
uchar* p;
int n = 0;
@@ -492,7 +492,7 @@ throw("Unexpected EOF in String");
/***********************************************************************/
/* Parse a JSON numeric value. */
/***********************************************************************/
-void BDOC::ParseNumeric(int& i, PBVAL vlp)
+void BDOC::ParseNumeric(size_t& i, PBVAL vlp)
{
char buf[50];
int n = 0;
diff --git a/storage/connect/bson.h b/storage/connect/bson.h
index d13ded72eb1..acc36e8e0ed 100644
--- a/storage/connect/bson.h
+++ b/storage/connect/bson.h
@@ -184,12 +184,12 @@ public:
PSZ Serialize(PGLOBAL g, PBVAL bvp, char* fn, int pretty);
protected:
- OFFSET ParseArray(int& i);
- OFFSET ParseObject(int& i);
- PBVAL ParseValue(int& i, PBVAL bvp);
- OFFSET ParseString(int& i);
- void ParseNumeric(int& i, PBVAL bvp);
- OFFSET ParseAsArray(int& i);
+ OFFSET ParseArray(size_t& i);
+ OFFSET ParseObject(size_t& i);
+ PBVAL ParseValue(size_t& i, PBVAL bvp);
+ OFFSET ParseString(size_t& i);
+ void ParseNumeric(size_t& i, PBVAL bvp);
+ OFFSET ParseAsArray(size_t& i);
bool SerializeArray(OFFSET arp, bool b);
bool SerializeObject(OFFSET obp);
bool SerializeValue(PBVAL vp, bool b = false);
@@ -197,7 +197,7 @@ protected:
// Members used when parsing and serializing
JOUT* jp; // Used with serialize
char* s; // The Json string to parse
- int len; // The Json string length
+ size_t len; // The Json string length
int pretty; // The pretty style of the file to parse
bool pty[3]; // Used to guess what pretty is
bool comma; // True if Pretty = 1
diff --git a/storage/connect/bsonudf.cpp b/storage/connect/bsonudf.cpp
index 18382c7a273..f377e578399 100644
--- a/storage/connect/bsonudf.cpp
+++ b/storage/connect/bsonudf.cpp
@@ -1670,7 +1670,7 @@ PBVAL BJNX::ParseJsonFile(PGLOBAL g, char *fn, int& pty, size_t& len)
len = (size_t)mm.lenL;
if (mm.lenH)
- len += ((size_t)mm.lenH * 0x000000001LL);
+ len += mm.lenH;
memory = (char *)mm.memory;