Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
3d257a9d
Commit
3d257a9d
authored
Nov 04, 2015
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add recursion limit handling to JSON parsing.
Fixes issue #932.
parent
b6a32e90
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
+20
-2
CodedInputStreamTest.cs
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
+2
-2
JsonParserTest.cs
csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+18
-0
JsonParser.cs
csharp/src/Google.Protobuf/JsonParser.cs
+0
-0
No files found.
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
View file @
3d257a9d
...
...
@@ -284,7 +284,7 @@ namespace Google.Protobuf
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
input
.
ReadBytes
());
}
private
static
TestRecursiveMessage
MakeRecursiveMessage
(
int
depth
)
internal
static
TestRecursiveMessage
MakeRecursiveMessage
(
int
depth
)
{
if
(
depth
==
0
)
{
...
...
@@ -296,7 +296,7 @@ namespace Google.Protobuf
}
}
private
static
void
AssertMessageDepth
(
TestRecursiveMessage
message
,
int
depth
)
internal
static
void
AssertMessageDepth
(
TestRecursiveMessage
message
,
int
depth
)
{
if
(
depth
==
0
)
{
...
...
csharp/src/Google.Protobuf.Test/JsonParserTest.cs
View file @
3d257a9d
...
...
@@ -723,5 +723,23 @@ namespace Google.Protobuf
string
json
=
"{} 10"
;
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
TestAllTypes
.
Parser
.
ParseJson
(
json
));
}
/// <summary>
/// JSON equivalent to <see cref="CodedInputStreamTest.MaliciousRecursion"/>
/// </summary>
[
Test
]
public
void
MaliciousRecursion
()
{
string
data64
=
CodedInputStreamTest
.
MakeRecursiveMessage
(
64
).
ToString
();
string
data65
=
CodedInputStreamTest
.
MakeRecursiveMessage
(
65
).
ToString
();
var
parser64
=
new
JsonParser
(
new
JsonParser
.
Settings
(
64
));
CodedInputStreamTest
.
AssertMessageDepth
(
parser64
.
Parse
<
TestRecursiveMessage
>(
data64
),
64
);
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
parser64
.
Parse
<
TestRecursiveMessage
>(
data65
));
var
parser63
=
new
JsonParser
(
new
JsonParser
.
Settings
(
63
));
Assert
.
Throws
<
InvalidProtocolBufferException
>(()
=>
parser63
.
Parse
<
TestRecursiveMessage
>(
data64
));
}
}
}
csharp/src/Google.Protobuf/JsonParser.cs
View file @
3d257a9d
This diff is collapsed.
Click to expand it.
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