diff options
author | Ed Tanous <edtanous@google.com> | 2022-01-07 20:28:45 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-01-12 22:00:37 +0300 |
commit | ca45aa3c416e55027b8d17078bac6493e81d564f (patch) | |
tree | 6b23f35cfba77f66557e78230b85684cef0f5c04 /include/multipart_parser.hpp | |
parent | 46ff87bade273c75f71f940c5770d30e7a29595b (diff) | |
download | bmcweb-ca45aa3c416e55027b8d17078bac6493e81d564f.tar.xz |
Enable checks for pointer arithmetic
Quite a few places we've disobeyed this rule, so simply ignore them for
now to avoid new issues popping up.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I3e518a8e8742279afb3ad1a9dad54006ed109fb1
Diffstat (limited to 'include/multipart_parser.hpp')
-rw-r--r-- | include/multipart_parser.hpp | 14 |
1 files changed, 12 insertions, 2 deletions
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++; } |