Skip to content

Commit 243722c

Browse files
committed
address PR comments
1 parent fdcf989 commit 243722c

File tree

5 files changed

+43
-51
lines changed

5 files changed

+43
-51
lines changed

cmake/external_dependencies.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ endif()
2020

2121
# Encryption control
2222
# TODO: BYO Crypto is not implemented for CRT/Was not working in the latest version of the SDK.
23-
if(NOT NO_ENCRYPTION)
23+
if(NO_ENCRYPTION)
2424
message(FATAL_ERROR "BYO_CRYPTO is not currently implemented and has been broken since version 1.9")
2525
set(ENABLE_INJECTED_ENCRYPTION ON)
2626
message(STATUS "Encryption: None")

src/aws-cpp-sdk-core/include/aws/core/utils/Array.h

+36-45
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <aws/core/utils/memory/AWSMemory.h>
1111
#include <aws/core/utils/memory/stl/AWSVector.h>
12+
#include <aws/core/utils/memory/stl/AWSString.h>
1213
#include <aws/crt/Types.h>
1314
#include <memory>
1415
#include <cassert>
@@ -39,7 +40,7 @@ namespace Aws
3940
* Create new empty array of size arraySize. Default argument is 0. If it is empty then no allocation happens.
4041
*/
4142
Array(size_t arraySize = 0) :
42-
m_size(arraySize),
43+
m_capacity(arraySize),
4344
m_length(arraySize),
4445
m_data(arraySize > 0 ? Aws::MakeUniqueArray<T>(arraySize, ARRAY_ALLOCATION_TAG) : nullptr)
4546
{
@@ -49,30 +50,25 @@ namespace Aws
4950
* Create new array and initialize it to a raw array
5051
*/
5152
Array(const T* arrayToCopy, size_t arraySize) :
52-
m_size(arraySize),
53+
m_capacity(arraySize),
5354
m_length(arraySize),
5455
m_data(nullptr)
5556
{
56-
if (arrayToCopy != nullptr && m_size > 0)
57+
if (arrayToCopy != nullptr && m_capacity > 0)
5758
{
58-
m_data.reset(Aws::NewArray<T>(m_size, ARRAY_ALLOCATION_TAG));
59-
60-
#ifdef _WIN32
61-
std::copy(arrayToCopy, arrayToCopy + arraySize, stdext::checked_array_iterator< T * >(m_data.get(), m_size));
62-
#else
59+
m_data.reset(Aws::NewArray<T>(m_capacity, ARRAY_ALLOCATION_TAG));
6360
std::copy(arrayToCopy, arrayToCopy + arraySize, m_data.get());
64-
#endif // MSVC
6561
}
6662
}
6763

6864
/**
6965
* Create new array with a pointer and its dimensions.
7066
*/
71-
Array(size_t m_size,
72-
size_t m_length,
67+
Array(size_t capacity,
68+
size_t length,
7369
UniqueArrayPtr<T> m_data)
74-
: m_size(m_size),
75-
m_length(m_length),
70+
: m_capacity(capacity),
71+
m_length(length),
7672
m_data(std::move(m_data))
7773
{
7874
}
@@ -88,20 +84,16 @@ namespace Aws
8884
totalSize += array->m_length;
8985
}
9086

91-
m_size = totalSize;
92-
m_data.reset(Aws::NewArray<T>(m_size, ARRAY_ALLOCATION_TAG));
87+
m_capacity = totalSize;
88+
m_data.reset(Aws::NewArray<T>(m_capacity, ARRAY_ALLOCATION_TAG));
9389

9490
size_t location = 0;
9591
for(auto& arr : toMerge)
9692
{
97-
if(arr->m_size > 0 && arr->m_data)
93+
if(arr->m_capacity > 0 && arr->m_data)
9894
{
9995
size_t arraySize = arr->m_length;
100-
#ifdef _WIN32
101-
std::copy(arr->m_data.get(), arr->m_data.get() + arraySize, stdext::checked_array_iterator< T * >(m_data.get() + location, m_length));
102-
#else
10396
std::copy(arr->m_data.get(), arr->m_data.get() + arraySize, m_data.get() + location);
104-
#endif // MSVC
10597
location += arraySize;
10698
}
10799
}
@@ -110,29 +102,24 @@ namespace Aws
110102

111103
Array(const Array& other)
112104
{
113-
m_size = other.m_size;
105+
m_capacity = other.m_capacity;
114106
m_length = other.m_length;
115107
m_data = nullptr;
116108

117-
if (m_size > 0)
109+
if (m_capacity > 0)
118110
{
119-
m_data.reset(Aws::NewArray<T>(m_size, ARRAY_ALLOCATION_TAG));
120-
121-
#ifdef _WIN32
122-
std::copy(other.m_data.get(), other.m_data.get() + other.m_size, stdext::checked_array_iterator< T * >(m_data.get(), m_size));
123-
#else
124-
std::copy(other.m_data.get(), other.m_data.get() + other.m_size, m_data.get());
125-
#endif // MSVC
111+
m_data.reset(Aws::NewArray<T>(m_capacity, ARRAY_ALLOCATION_TAG));
112+
std::copy(other.m_data.get(), other.m_data.get() + other.m_capacity, m_data.get());
126113
}
127114
}
128115

129116
//move c_tor
130117
Array(Array&& other) noexcept:
131-
m_size(other.m_size),
118+
m_capacity(other.m_capacity),
132119
m_length(other.m_length),
133120
m_data(std::move(other.m_data))
134121
{
135-
other.m_size = 0;
122+
other.m_capacity = 0;
136123
other.m_data = nullptr;
137124
}
138125

@@ -145,39 +132,43 @@ namespace Aws
145132
return *this;
146133
}
147134

148-
m_size = other.m_size;
135+
m_capacity = other.m_capacity;
149136
m_length = other.m_length;
150137
m_data = nullptr;
151138

152-
if (m_size > 0)
139+
if (m_capacity > 0)
153140
{
154-
m_data.reset(Aws::NewArray<T>(m_size, ARRAY_ALLOCATION_TAG));
155-
156-
#ifdef _WIN32
157-
std::copy(other.m_data.get(), other.m_data.get() + other.m_length, stdext::checked_array_iterator< T * >(m_data.get(), m_size));
158-
#else
141+
m_data.reset(Aws::NewArray<T>(m_capacity, ARRAY_ALLOCATION_TAG));
159142
std::copy(other.m_data.get(), other.m_data.get() + other.m_length, m_data.get());
160-
#endif // MSVC
161143
}
162144

163145
return *this;
164146
}
165147

166148
Array& operator=(Array&& other) noexcept
167149
{
168-
m_size = other.m_size;
150+
m_capacity = other.m_capacity;
169151
m_length = other.m_length;
170152
m_data = std::move(other.m_data);
171153

172154
return *this;
173155
}
174156

157+
Array(const Aws::String& string):
158+
m_capacity(string.capacity()),
159+
m_length(string.length()),
160+
m_data(nullptr)
161+
{
162+
m_data.reset(Aws::NewArray<unsigned char>(m_capacity, ARRAY_ALLOCATION_TAG));
163+
std::copy(string.c_str(), string.c_str() + string.length(), m_data.get());
164+
}
165+
175166
bool operator==(const Array& other) const
176167
{
177168
if (this == &other)
178169
return true;
179170

180-
if (m_size == 0 && other.m_size == 0)
171+
if (m_capacity == 0 && other.m_capacity == 0)
181172
{
182173
return true;
183174
}
@@ -187,7 +178,7 @@ namespace Aws
187178
return false;
188179
}
189180

190-
if (m_length == other.m_length && m_size == other.m_size && m_data && other.m_data)
181+
if (m_length == other.m_length && m_capacity == other.m_capacity && m_data && other.m_data)
191182
{
192183
for (unsigned i = 0; i < m_length; ++i)
193184
{
@@ -235,7 +226,7 @@ namespace Aws
235226

236227
inline size_t GetSize() const
237228
{
238-
return m_size;
229+
return m_capacity;
239230
}
240231

241232
inline T* GetUnderlyingData() const
@@ -249,7 +240,7 @@ namespace Aws
249240
}
250241

251242
protected:
252-
size_t m_size;
243+
size_t m_capacity;
253244
size_t m_length;
254245
Aws::UniqueArrayPtr<T> m_data;
255246
};
@@ -285,7 +276,7 @@ namespace Aws
285276

286277
CryptoBuffer& operator=(Crt::ByteBuf&& other) noexcept
287278
{
288-
m_size = other.len;
279+
m_capacity = other.len;
289280
m_length = other.len;
290281
m_data.reset(other.buffer);
291282
other.capacity = 0;

src/aws-cpp-sdk-core/source/auth/signer/AWSAuthV4Signer.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,7 @@ Aws::Utils::ByteBuffer AWSAuthV4Signer::ComputeHash(const Aws::String& secretKey
560560
{
561561
Aws::String signingKey(Aws::Auth::AWSAuthHelper::SIGNING_KEY);
562562
signingKey.append(secretKey);
563-
auto kDate = HashingUtils::CalculateSHA256HMAC(
564-
ByteBuffer((unsigned char *) simpleDate.c_str(), simpleDate.length()),
565-
ByteBuffer((unsigned char *) signingKey.c_str(), signingKey.length()));
563+
auto kDate = HashingUtils::CalculateSHA256HMAC(simpleDate, signingKey);
566564

567565
if (kDate.GetLength() == 0)
568566
{

src/aws-cpp-sdk-core/source/utils/crypto/crt/CRTSecureRandomBytes.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ namespace Aws
1414
void CRTSecureRandomBytes::GetBytes(unsigned char *buffer, std::size_t bufferSize)
1515
{
1616
auto outputBuf = Crt::ByteBufFromEmptyArray(buffer, bufferSize);
17-
(void)Crt::Crypto::GenerateRandomBytes(outputBuf, bufferSize);
17+
if (!Crt::Crypto::GenerateRandomBytes(outputBuf, bufferSize))
18+
{
19+
AWS_UNREACHABLE();
20+
}
1821
}
1922
}
2023
}

tests/aws-cpp-sdk-mediastore-data-integration-tests/MediaStoreDataTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace
109109
static Aws::String GetTestContainerName()
110110
{
111111
// "-" is not allowed in container name, convert uuid to its hex.
112-
static const std::string suffix = HashingUtils::HexEncode(ByteBuffer(Aws::Utils::UUID::RandomUUID())).c_str();
112+
static const std::string suffix = HashingUtils::HexEncode(ByteBuffer(Aws::Utils::UUID::RandomUUID().operator ByteBuffer())).c_str();
113113
Aws::StringStream ss;
114114
ss << Aws::Testing::GetAwsResourcePrefix() << TEST_CONTAINER_NAME_BASE << suffix;
115115
return Aws::Utils::StringUtils::ToLower(ss.str().c_str());

0 commit comments

Comments
 (0)