Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
capnproto
Commits
752e0abc
Commit
752e0abc
authored
Aug 28, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bugs in format-detection heuristics.
parent
0d872f83
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
capnp.c++
c++/src/capnp/compiler/capnp.c++
+19
-4
No files found.
c++/src/capnp/compiler/capnp.c++
View file @
752e0abc
...
@@ -643,12 +643,24 @@ private:
...
@@ -643,12 +643,24 @@ private:
return
p
==
PLAUSIBLE
||
p
==
WRONG_TYPE
;
return
p
==
PLAUSIBLE
||
p
==
WRONG_TYPE
;
}
}
Plausibility
isPlausiblyFlat
(
kj
::
ArrayPtr
<
const
byte
>
prefix
)
{
Plausibility
isPlausiblyFlat
(
kj
::
ArrayPtr
<
const
byte
>
prefix
,
uint
segmentCount
=
1
)
{
if
(
prefix
.
size
()
<
8
)
{
if
(
prefix
.
size
()
<
8
)
{
// Not enough prefix to say.
// Not enough prefix to say.
return
PLAUSIBLE
;
return
PLAUSIBLE
;
}
}
if
((
prefix
[
0
]
&
3
)
==
2
)
{
// Far pointer. Verify the segment ID.
uint32_t
segmentId
=
prefix
[
4
]
|
(
prefix
[
5
]
<<
8
)
|
(
prefix
[
6
]
<<
16
)
|
(
prefix
[
7
]
<<
24
);
if
(
segmentId
==
0
||
segmentId
>=
segmentCount
)
{
KJ_DBG
(
segmentId
,
segmentCount
);
return
IMPOSSIBLE
;
}
else
{
return
PLAUSIBLE
;
}
}
if
((
prefix
[
0
]
&
3
)
!=
0
)
{
if
((
prefix
[
0
]
&
3
)
!=
0
)
{
// Not a struct pointer.
// Not a struct pointer.
return
IMPOSSIBLE
;
return
IMPOSSIBLE
;
...
@@ -700,6 +712,9 @@ private:
...
@@ -700,6 +712,9 @@ private:
uint32_t
segmentCount
=
prefix
[
0
]
|
(
prefix
[
1
]
<<
8
)
uint32_t
segmentCount
=
prefix
[
0
]
|
(
prefix
[
1
]
<<
8
)
|
(
prefix
[
2
]
<<
16
)
|
(
prefix
[
3
]
<<
24
);
|
(
prefix
[
2
]
<<
16
)
|
(
prefix
[
3
]
<<
24
);
// Actually, the bytes store segmentCount - 1.
++
segmentCount
;
if
(
segmentCount
>
65536
)
{
if
(
segmentCount
>
65536
)
{
// While technically possible, this is so implausible that we should mark it impossible.
// While technically possible, this is so implausible that we should mark it impossible.
// This helps to make sure we fail fast on packed input.
// This helps to make sure we fail fast on packed input.
...
@@ -709,8 +724,8 @@ private:
...
@@ -709,8 +724,8 @@ private:
return
IMPLAUSIBLE
;
return
IMPLAUSIBLE
;
}
}
uint32_t
segment0Size
=
prefix
[
5
]
|
(
prefix
[
6
]
<<
8
)
uint32_t
segment0Size
=
prefix
[
4
]
|
(
prefix
[
5
]
<<
8
)
|
(
prefix
[
7
]
<<
16
)
|
(
prefix
[
8
]
<<
24
);
|
(
prefix
[
6
]
<<
16
)
|
(
prefix
[
7
]
<<
24
);
if
(
segment0Size
>
(
1
<<
27
))
{
if
(
segment0Size
>
(
1
<<
27
))
{
// Segment larger than 1G seems implausible.
// Segment larger than 1G seems implausible.
...
@@ -728,7 +743,7 @@ private:
...
@@ -728,7 +743,7 @@ private:
return
PLAUSIBLE
;
return
PLAUSIBLE
;
}
}
return
isPlausiblyFlat
(
prefix
.
slice
(
segment0Offset
,
prefix
.
size
()));
return
isPlausiblyFlat
(
prefix
.
slice
(
segment0Offset
,
prefix
.
size
())
,
segmentCount
);
}
}
Plausibility
isPlausiblyPacked
(
kj
::
ArrayPtr
<
const
byte
>
prefix
)
{
Plausibility
isPlausiblyPacked
(
kj
::
ArrayPtr
<
const
byte
>
prefix
)
{
...
...
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