Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
2f899756
Unverified
Commit
2f899756
authored
Oct 21, 2021
by
Robert Sebastian Herlim
Committed by
GitHub
Oct 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use static_cast<unsigned char> on DecodeBase64 to prevent SEGV on negative values (#1051)
parent
1713859b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletions
+15
-1
src/binary.cpp
+1
-1
test/binary_test.cpp
+14
-0
No files found.
src/binary.cpp
View file @
2f899756
...
@@ -79,7 +79,7 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {
...
@@ -79,7 +79,7 @@ std::vector<unsigned char> DecodeBase64(const std::string &input) {
// skip newlines
// skip newlines
continue
;
continue
;
}
}
unsigned
char
d
=
decoding
[
static_cast
<
unsigned
>
(
input
[
i
])];
unsigned
char
d
=
decoding
[
static_cast
<
unsigned
char
>
(
input
[
i
])];
if
(
d
==
255
)
if
(
d
==
255
)
return
ret_type
();
return
ret_type
();
...
...
test/binary_test.cpp
0 → 100644
View file @
2f899756
#include "gtest/gtest.h"
#include <yaml-cpp/binary.h>
TEST
(
BinaryTest
,
DecodingSimple
)
{
std
::
string
input
{
90
,
71
,
86
,
104
,
90
,
71
,
74
,
108
,
90
,
87
,
89
,
61
};
const
std
::
vector
<
unsigned
char
>
&
result
=
YAML
::
DecodeBase64
(
input
);
EXPECT_EQ
(
std
::
string
(
result
.
begin
(),
result
.
end
()),
"deadbeef"
);
}
TEST
(
BinaryTest
,
DecodingNoCrashOnNegative
)
{
std
::
string
input
{
-
58
,
-
1
,
-
99
,
109
};
const
std
::
vector
<
unsigned
char
>
&
result
=
YAML
::
DecodeBase64
(
input
);
EXPECT_TRUE
(
result
.
empty
());
}
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