summaryrefslogtreecommitdiff
path: root/http/mutual_tls.hpp
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2023-05-11 04:03:19 +0300
committerPatrick Williams <patrick@stwcx.xyz>2023-05-11 06:24:35 +0300
commit3d7fc71e989f530b1a5c61615713e4ba54fce9cc (patch)
treea850f4395e1d85009d2c58a9a349e8f9dadd9d2c /http/mutual_tls.hpp
parentad7fa9027b890255b802941558405c04d1cfb23b (diff)
downloadbmcweb-3d7fc71e989f530b1a5c61615713e4ba54fce9cc.tar.xz
mutual-tls: fix clang-tidy warning
``` ../http/mutual_tls.hpp:77:35: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] unsigned char usageChar = usage->data[i]; ``` Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: Icc6905f31fdd54b683fe7807eb72e9b78437b2d1
Diffstat (limited to 'http/mutual_tls.hpp')
-rw-r--r--http/mutual_tls.hpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/http/mutual_tls.hpp b/http/mutual_tls.hpp
index aee85c265e..f8af0f6f57 100644
--- a/http/mutual_tls.hpp
+++ b/http/mutual_tls.hpp
@@ -10,6 +10,7 @@
#include <boost/asio/ssl/verify_context.hpp>
#include <memory>
+#include <span>
inline std::shared_ptr<persistent_data::UserSession>
verifyMtlsUser(const boost::asio::ip::address& clientIp,
@@ -65,16 +66,15 @@ inline std::shared_ptr<persistent_data::UserSession>
ASN1_BIT_STRING* usage = static_cast<ASN1_BIT_STRING*>(
X509_get_ext_d2i(peerCert, NID_key_usage, nullptr, nullptr));
- if (usage == nullptr)
+ if ((usage == nullptr) || (usage->data == nullptr))
{
BMCWEB_LOG_DEBUG << "TLS usage is null";
return nullptr;
}
- for (int i = 0; i < usage->length; i++)
+ for (auto usageChar :
+ std::span(usage->data, static_cast<size_t>(usage->length)))
{
- // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
- unsigned char usageChar = usage->data[i];
if (KU_DIGITAL_SIGNATURE & usageChar)
{
isKeyUsageDigitalSignature = true;