C++11 std::array rewrite for memory safety [3/19]
Split from: https://chromium-review.googlesource.com/c/chromium/src/+/6004959/21 Generated patch --------------- - Tool: ./tool/clang/spanify/rewrite-multiple-platform.sh - Platform: Linux. - Filter: This includes 2400/4222 patches. I included the std::array ones and excluded build errors. Google announcement: -------------------- https://groups.google.com/a/google.com/g/chrome-memory-safety/c/RMiO4gaVLQA/m/Yz-3NCObAgAJ Benchmarks: ---------- See design doc and https://chromium-review.googlesource.com/c/chromium/src/+/6004959/21 Description ----------- The consensus during the memory safety summit was to begin rewriting relevant C-style arrays to C++11 std::array. It can be done immediately, offers better developer ergonomics, and fix large chunks of the -Wunsafe-buffer-usage errors in Chrome. To clarify, this effort is complementary to the longer plan work with enabling -fsanitize=array-bounds, and we plan to leverage both, especially for protecting 3p code. [Attached] is a document detailing the rationale, benefits, and considerations for potential compile-time and performance impacts. [Attached]:https://docs.google.com/document/d/1z5aBDg26lHmNDjXRCysElWKx7E4PAJXqykI_k7ondJI/edit?tab=t.0#heading=h.cqgo7wvp0kzt NO_IFTTT=No need to update base/debug/stack_trace.h Bug: 378069401 Change-Id: I3954f5f56075e55edadf8c00ad34fb858cbaacc6 R: dcheng@chromium.org AX-Relnotes: n/a. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6043821 Commit-Queue: Daniel Cheng <dcheng@chromium.org> Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Owners-Override: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1394426}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
8e0e4c2bb3
commit
1a6fc641b4
components
affiliations
core
browser
blocklist
opt_out_blocklist
browsing_topics
certificate_transparency
content_settings
core
crx_file
input
password_manager
core
browser
query_parser
safe_search_api
url_formatter
url_matcher
@ -2,13 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "components/safe_search_api/safe_search/safe_search_url_checker_client.h"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
@ -47,13 +43,17 @@ std::string BuildResponse(bool is_porn) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* kURLs[] = {
|
||||
"http://www.randomsite1.com", "http://www.randomsite2.com",
|
||||
"http://www.randomsite3.com", "http://www.randomsite4.com",
|
||||
"http://www.randomsite5.com", "http://www.randomsite6.com",
|
||||
"http://www.randomsite7.com", "http://www.randomsite8.com",
|
||||
auto kURLs = std::to_array<const char*>({
|
||||
"http://www.randomsite1.com",
|
||||
"http://www.randomsite2.com",
|
||||
"http://www.randomsite3.com",
|
||||
"http://www.randomsite4.com",
|
||||
"http://www.randomsite5.com",
|
||||
"http://www.randomsite6.com",
|
||||
"http://www.randomsite7.com",
|
||||
"http://www.randomsite8.com",
|
||||
"http://www.randomsite9.com",
|
||||
};
|
||||
});
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -2,16 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "components/safe_search_api/url_checker.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -38,13 +34,17 @@ namespace {
|
||||
|
||||
constexpr size_t kCacheSize = 2;
|
||||
|
||||
const char* kURLs[] = {
|
||||
"http://www.randomsite1.com", "http://www.randomsite2.com",
|
||||
"http://www.randomsite3.com", "http://www.randomsite4.com",
|
||||
"http://www.randomsite5.com", "http://www.randomsite6.com",
|
||||
"http://www.randomsite7.com", "http://www.randomsite8.com",
|
||||
auto kURLs = std::to_array<const char*>({
|
||||
"http://www.randomsite1.com",
|
||||
"http://www.randomsite2.com",
|
||||
"http://www.randomsite3.com",
|
||||
"http://www.randomsite4.com",
|
||||
"http://www.randomsite5.com",
|
||||
"http://www.randomsite6.com",
|
||||
"http://www.randomsite7.com",
|
||||
"http://www.randomsite8.com",
|
||||
"http://www.randomsite9.com",
|
||||
};
|
||||
});
|
||||
|
||||
ClientClassification ToAPIClassification(Classification classification,
|
||||
bool uncertain) {
|
||||
|
Reference in New Issue
Block a user