mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Use static_cast<unsigned char> on DecodeBase64 to prevent SEGV on negative values (#1051)
This commit is contained in:

committed by
GitHub

parent
1713859b05
commit
2f8997565b
14
test/binary_test.cpp
Normal file
14
test/binary_test.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#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());
|
||||
}
|
Reference in New Issue
Block a user