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
365de898
Commit
365de898
authored
Oct 12, 2017
by
Kenton Varda
Committed by
GitHub
Oct 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #570 from ecatmur/base64-invalid-read
Don't read past the end of the base64 decode out buffer.
parents
ba889908
0771d33b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
encoding-test.c++
c++/src/kj/encoding-test.c++
+12
-0
encoding.c++
c++/src/kj/encoding.c++
+1
-1
No files found.
c++/src/kj/encoding-test.c++
View file @
365de898
...
...
@@ -268,12 +268,24 @@ KJ_TEST("C escape encoding/decoding") {
}
KJ_TEST
(
"base64 encoding/decoding"
)
{
{
auto
encoded
=
encodeBase64
(
StringPtr
(
""
).
asBytes
(),
false
);
KJ_EXPECT
(
encoded
==
""
,
encoded
,
encoded
.
size
());
KJ_EXPECT
(
heapString
(
decodeBase64
(
encoded
.
asArray
()).
asChars
())
==
""
);
}
{
auto
encoded
=
encodeBase64
(
StringPtr
(
"foo"
).
asBytes
(),
false
);
KJ_EXPECT
(
encoded
==
"Zm9v"
,
encoded
,
encoded
.
size
());
KJ_EXPECT
(
heapString
(
decodeBase64
(
encoded
.
asArray
()).
asChars
())
==
"foo"
);
}
{
auto
encoded
=
encodeBase64
(
StringPtr
(
"quux"
).
asBytes
(),
false
);
KJ_EXPECT
(
encoded
==
"cXV1eA=="
,
encoded
,
encoded
.
size
());
KJ_EXPECT
(
heapString
(
decodeBase64
(
encoded
.
asArray
()).
asChars
())
==
"quux"
);
}
{
auto
encoded
=
encodeBase64
(
StringPtr
(
"corge"
).
asBytes
(),
false
);
KJ_EXPECT
(
encoded
==
"Y29yZ2U="
,
encoded
);
...
...
c++/src/kj/encoding.c++
View file @
365de898
...
...
@@ -697,7 +697,7 @@ int base64_decode_block(const char* code_in, const int length_in,
do
{
if
(
codechar
==
code_in
+
length_in
)
{
state_in
->
step
=
step_a
;
state_in
->
plainchar
=
*
plainchar
;
state_in
->
plainchar
=
'\0'
;
return
plainchar
-
plaintext_out
;
}
fragment
=
(
char
)
base64_decode_value
(
*
codechar
++
);
...
...
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