diff options
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | http/http_connection.hpp | 6 | ||||
-rw-r--r-- | include/async_resolve.hpp | 1 | ||||
-rw-r--r-- | include/ibm/locks.hpp | 11 | ||||
-rw-r--r-- | include/json_html_serializer.hpp | 3 | ||||
-rw-r--r-- | include/multipart_parser.hpp | 14 | ||||
-rw-r--r-- | include/pam_authenticate.hpp | 2 | ||||
-rw-r--r-- | redfish-core/lib/log_services.hpp | 11 |
8 files changed, 40 insertions, 9 deletions
diff --git a/.clang-tidy b/.clang-tidy index 61f2c68d82..eae3c722cb 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -202,6 +202,7 @@ clang-analyzer-valist.ValistBase, clang-analyzer-webkit.NoUncountedMemberChecker, clang-analyzer-webkit.RefCntblBaseVirtualDtor, cppcoreguidelines-init-variables, +cppcoreguidelines-pro-bounds-pointer-arithmetic, cppcoreguidelines-pro-type-reinterpret-cast, cppcoreguidelines-special-member-functions, misc-misplaced-const, diff --git a/http/http_connection.hpp b/http/http_connection.hpp index 840f2b6ceb..ad6855f434 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp @@ -182,11 +182,13 @@ class Connection : for (int i = 0; i < usage->length; i++) { - if (KU_DIGITAL_SIGNATURE & usage->data[i]) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + unsigned char usageChar = usage->data[i]; + if (KU_DIGITAL_SIGNATURE & usageChar) { isKeyUsageDigitalSignature = true; } - if (KU_KEY_AGREEMENT & usage->data[i]) + if (KU_KEY_AGREEMENT & usageChar) { isKeyUsageKeyAgreement = true; } diff --git a/include/async_resolve.hpp b/include/async_resolve.hpp index c69fd87129..0945001537 100644 --- a/include/async_resolve.hpp +++ b/include/async_resolve.hpp @@ -80,6 +80,7 @@ class Resolver } uint16_t portNum = 0; auto it = std::from_chars( + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) port.data(), port.data() + port.size(), portNum); if (it.ec != std::errc()) { diff --git a/include/ibm/locks.hpp b/include/ibm/locks.hpp index 4fbb50360d..5a86d09dec 100644 --- a/include/ibm/locks.hpp +++ b/include/ibm/locks.hpp @@ -535,9 +535,14 @@ inline bool Lock::checkByte(uint64_t resourceId1, uint64_t resourceId2, // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) uint8_t* q = reinterpret_cast<uint8_t*>(&resourceId2); - BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(p[position]) << "," - << std::to_string(q[position]); - if (p[position] != q[position]) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t pPosition = p[position]; + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t qPosition = q[position]; + + BMCWEB_LOG_DEBUG << "Comparing bytes " << std::to_string(pPosition) << "," + << std::to_string(qPosition); + if (pPosition != qPosition) { return false; } diff --git a/include/json_html_serializer.hpp b/include/json_html_serializer.hpp index 3efc224444..4969d27278 100644 --- a/include/json_html_serializer.hpp +++ b/include/json_html_serializer.hpp @@ -353,6 +353,7 @@ void dumpInteger(std::string& out, NumberType number) // jump to the end to generate the string from backward // so we later avoid reversing the result + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) bufferPtr += nChars; // Fast int2ascii implementation inspired by "Fastware" talk by Andrei @@ -384,6 +385,8 @@ inline void dumpfloat(std::string& out, double number, { std::array<char, 64> numberbuffer{{}}; char* begin = numberbuffer.data(); + + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) ::nlohmann::detail::to_chars(begin, begin + numberbuffer.size(), number); out += begin; diff --git a/include/multipart_parser.hpp b/include/multipart_parser.hpp index 3728311fbe..e385558037 100644 --- a/include/multipart_parser.hpp +++ b/include/multipart_parser.hpp @@ -79,6 +79,7 @@ class MultipartParser for (size_t i = 0; i < len; i++) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) char c = buffer[i]; switch (state) { @@ -139,6 +140,8 @@ class MultipartParser { return ParserError::ERROR_EMPTY_HEADER; } + + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) currentHeaderName.append(buffer + headerFieldMark, i - headerFieldMark); state = State::HEADER_VALUE_START; @@ -161,6 +164,7 @@ class MultipartParser case State::HEADER_VALUE: if (c == cr) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) std::string_view value(buffer + headerValueMark, i - headerValueMark); mime_fields.rbegin()->fields.set(currentHeaderName, @@ -190,6 +194,8 @@ class MultipartParser if (index == 0) { skipNonBoundary(buffer, len, boundary.size() - 1, i); + + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) c = buffer[i]; } processPartData(prevIndex, index, buffer, i, c, state); @@ -229,6 +235,7 @@ class MultipartParser // boyer-moore derived algorithm to safely skip non-boundary data while (i + boundary.size() <= len) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (isBoundaryChar(buffer[i + boundaryEnd])) { break; @@ -248,8 +255,11 @@ class MultipartParser { if (index == 0) { - mime_fields.rbegin()->content += std::string_view( - buffer + partDataMark, i - partDataMark); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + const char* start = buffer + partDataMark; + size_t size = i - partDataMark; + mime_fields.rbegin()->content += + std::string_view(start, size); } index++; } diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp index 0ce0bb4a84..1459ea6112 100644 --- a/include/pam_authenticate.hpp +++ b/include/pam_authenticate.hpp @@ -24,6 +24,7 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg, for (int i = 0; i < numMsg; ++i) { /* Ignore all PAM messages except prompting for hidden input */ + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (msg[i]->msg_style != PAM_PROMPT_ECHO_OFF) { continue; @@ -66,6 +67,7 @@ inline int pamFunctionConversation(int numMsg, const struct pam_message** msg, // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) *resp = reinterpret_cast<pam_response*>(ptr); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) resp[i]->resp = pass; return PAM_SUCCESS; diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 2cd35df428..a33e0612b9 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -2009,8 +2009,11 @@ inline void requestRoutesSystemHostLoggerLogEntry(App& app) const std::string& targetID = param; uint64_t idInt = 0; - auto [ptr, ec] = std::from_chars( - targetID.data(), targetID.data() + targetID.size(), idInt); + + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + const char* end = targetID.data() + targetID.size(); + + auto [ptr, ec] = std::from_chars(targetID.data(), end, idInt); if (ec == std::errc::invalid_argument) { messages::resourceMissingAtURI(asyncResp->res, targetID); @@ -3389,7 +3392,9 @@ inline static bool parsePostCode(const std::string& postCodeID, return false; } + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) const char* start = split[0].data() + 1; + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) const char* end = split[0].data() + split[0].size(); auto [ptrIndex, ecIndex] = std::from_chars(start, end, index); @@ -3399,6 +3404,8 @@ inline static bool parsePostCode(const std::string& postCodeID, } start = split[1].data(); + + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) end = split[1].data() + split[1].size(); auto [ptrValue, ecValue] = std::from_chars(start, end, currentValue); if (ptrValue != end || ecValue != std::errc()) |