Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
c04ae0d3
Commit
c04ae0d3
authored
Feb 03, 2021
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix of crashes of connect engine.
Use size_t everywhere and remove suspicious expression.
parent
87bf594b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
24 deletions
+24
-24
storage/connect/bson.cpp
storage/connect/bson.cpp
+16
-16
storage/connect/bson.h
storage/connect/bson.h
+7
-7
storage/connect/bsonudf.cpp
storage/connect/bsonudf.cpp
+1
-1
No files found.
storage/connect/bson.cpp
View file @
c04ae0d3
...
...
@@ -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
(
in
t
&
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
(
in
t
&
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
(
in
t
&
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
(
in
t
&
i
,
PBVAL
bvp
)
PBVAL
BDOC
::
ParseValue
(
size_
t
&
i
,
PBVAL
bvp
)
{
for
(;
i
<
len
;
i
++
)
switch
(
s
[
i
])
{
...
...
@@ -398,14 +398,14 @@ PBVAL BDOC::ParseValue(int& i, PBVAL bvp)
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
(
in
t
&
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
(
in
t
&
i
,
PBVAL
vlp
)
void
BDOC
::
ParseNumeric
(
size_
t
&
i
,
PBVAL
vlp
)
{
char
buf
[
50
];
int
n
=
0
;
...
...
storage/connect/bson.h
View file @
c04ae0d3
...
...
@@ -184,12 +184,12 @@ class BDOC : public BJSON {
PSZ
Serialize
(
PGLOBAL
g
,
PBVAL
bvp
,
char
*
fn
,
int
pretty
);
protected:
OFFSET
ParseArray
(
in
t
&
i
);
OFFSET
ParseObject
(
in
t
&
i
);
PBVAL
ParseValue
(
in
t
&
i
,
PBVAL
bvp
);
OFFSET
ParseString
(
in
t
&
i
);
void
ParseNumeric
(
in
t
&
i
,
PBVAL
bvp
);
OFFSET
ParseAsArray
(
in
t
&
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 @@ class BDOC : public BJSON {
// 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
...
...
storage/connect/bsonudf.cpp
View file @
c04ae0d3
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment