[CodeHealth] Enable -Wunsafe-buffer-usage across brave (#26027)
[CodeHealth] Enable `-Wunsafe-buffer-usage` acrosss brave This PR removes `brave/` from the blanket exclusion for `-Wunsafe-buffer-usage`, and adds only certain third party subpaths to it. Additionally, in order correct the ensuing warning violations, this PR adds to individual files exclusion annotations, that we can revisit gradually. Having this warning on will prevent further violations from popping up in new places in the codebase. A significant amount of effort has already been employed in correcting some of these unsafe buffer usages. For reference: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/unsafe_buffers.md Resolves https://github.com/brave/brave-browser/issues/41660
This commit is contained in:
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
@@ -113,8 +113,8 @@ class MacAddressProcessor {
|
||||
}
|
||||
|
||||
constexpr size_t kMacLength = 6u;
|
||||
auto mac_address_bytes =
|
||||
base::as_bytes(base::make_span(ifinfo.ifr_hwaddr.sa_data, kMacLength));
|
||||
auto mac_address_bytes = base::as_bytes(
|
||||
UNSAFE_TODO(base::make_span(ifinfo.ifr_hwaddr.sa_data, kMacLength)));
|
||||
if (!is_valid_mac_address_callback_.Run(mac_address_bytes)) {
|
||||
return keep_going;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class MacAddressProcessor {
|
||||
const char* const prefixes[],
|
||||
size_t prefixes_count) {
|
||||
for (size_t i = 0; i < prefixes_count; i++) {
|
||||
if (strncmp(prefixes[i], name, strlen(prefixes[i])) == 0) {
|
||||
if (UNSAFE_TODO(strncmp(prefixes[i], name, strlen(prefixes[i]))) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ std::string FindBSDNameOfSystemDisk() {
|
||||
|
||||
std::string root_bsd_name;
|
||||
for (int i = 0; i < count; i++) {
|
||||
const struct statfs& volume = mounted_volumes[i];
|
||||
const struct statfs& volume = UNSAFE_TODO(mounted_volumes[i]);
|
||||
if (std::string(volume.f_mntonname) == kRootDirectory) {
|
||||
root_bsd_name = std::string(volume.f_mntfromname);
|
||||
break;
|
||||
@@ -138,9 +138,9 @@ class MacAddressProcessor {
|
||||
return keep_going;
|
||||
}
|
||||
|
||||
auto mac_address_bytes = base::as_bytes(base::make_span(
|
||||
auto mac_address_bytes = base::as_bytes(UNSAFE_TODO(base::make_span(
|
||||
CFDataGetBytePtr(mac_address_data.get()),
|
||||
base::checked_cast<size_t>(CFDataGetLength(mac_address_data.get()))));
|
||||
base::checked_cast<size_t>(CFDataGetLength(mac_address_data.get())))));
|
||||
if (!is_valid_mac_address_callback_.Run(mac_address_bytes)) {
|
||||
return keep_going;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ std::string GetMacAddressFromGetIfTable2(
|
||||
|
||||
MacAddressProcessor processor(std::move(is_valid_mac_address_callback));
|
||||
for (size_t i = 0; i < if_table->NumEntries; i++) {
|
||||
processor.ProcessInterfaceRow(&(if_table->Table[i]));
|
||||
processor.ProcessInterfaceRow(&UNSAFE_TODO((if_table->Table[i])));
|
||||
}
|
||||
|
||||
if (if_table != NULL) {
|
||||
|
||||
@@ -208,7 +208,7 @@ base::FilePath AdBlockServiceTest::MakeFileInTempDir(
|
||||
base::File::FLAG_WRITE |
|
||||
base::File::FLAG_READ);
|
||||
EXPECT_TRUE(list_file.IsValid());
|
||||
list_file.Write(0, contents.c_str(), contents.size());
|
||||
UNSAFE_TODO(list_file.Write(0, contents.c_str(), contents.size()));
|
||||
list_file.Close();
|
||||
|
||||
temp_dirs_.push_back(std::move(dir));
|
||||
|
||||
@@ -162,7 +162,8 @@ IN_PROC_BROWSER_TEST_F(BraveStatsUpdaterBrowserTest,
|
||||
WaitForStandardStatsUpdatedCallback();
|
||||
|
||||
// We get //1/usage/brave-core here, so ignore the first slash.
|
||||
EXPECT_STREQ(GetUpdateURL().path().c_str() + 1, "/1/usage/brave-core");
|
||||
EXPECT_STREQ(UNSAFE_TODO(GetUpdateURL().path().c_str() + 1),
|
||||
"/1/usage/brave-core");
|
||||
|
||||
// First check preference should now be true
|
||||
EXPECT_TRUE(g_browser_process->local_state()->GetBoolean(kFirstCheckMade));
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/browser/default_protocol_handler_utils_win.h"
|
||||
|
||||
#include <shobjidl.h>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/path_service.h"
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/base64url.h"
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/functional/bind.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "brave/browser/ui/views/brave_ads/color_util.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
|
||||
namespace brave_ads {
|
||||
@@ -28,7 +29,7 @@ bool RgbStringToSkColor(std::string_view rgb, SkColor* color) {
|
||||
&component)) {
|
||||
return false;
|
||||
}
|
||||
components[i] = component;
|
||||
UNSAFE_TODO(components[i] = component);
|
||||
}
|
||||
|
||||
*color = SkColorSetRGB(components[0], components[1], components[2]);
|
||||
|
||||
@@ -128,7 +128,8 @@ class OkButton : public views::LabelButton {
|
||||
ui::NativeTheme::GetInstanceForNativeUi()->ShouldUseDarkColors();
|
||||
SetBackground(CreateBackgroundFromPainter(
|
||||
views::Painter::CreateRoundRectWith1PxBorderPainter(
|
||||
kBgColor[theme][GetVisualState()], SK_ColorTRANSPARENT, 100)));
|
||||
UNSAFE_TODO(kBgColor[theme][GetVisualState()]), SK_ColorTRANSPARENT,
|
||||
100)));
|
||||
}
|
||||
|
||||
void OnThemeChanged() override {
|
||||
|
||||
@@ -69,7 +69,7 @@ AIChatUI::AIChatUI(content::WebUI* web_ui)
|
||||
|
||||
webui::SetupWebUIDataSource(
|
||||
untrusted_source,
|
||||
base::make_span(kAiChatUiGenerated, kAiChatUiGeneratedSize),
|
||||
UNSAFE_TODO(base::make_span(kAiChatUiGenerated, kAiChatUiGeneratedSize)),
|
||||
IDR_CHAT_UI_HTML);
|
||||
|
||||
untrusted_source->AddResourcePath("styles.css", IDR_CHAT_UI_CSS);
|
||||
|
||||
@@ -294,7 +294,9 @@ void CreateAndAddRewardsPageDataSource(content::WebUI& web_ui,
|
||||
auto* source = content::WebUIDataSource::CreateAndAdd(browser_context, host);
|
||||
|
||||
webui::SetupWebUIDataSource(
|
||||
source, base::make_span(kRewardsPageGenerated, kRewardsPageGeneratedSize),
|
||||
source,
|
||||
UNSAFE_TODO(
|
||||
base::make_span(kRewardsPageGenerated, kRewardsPageGeneratedSize)),
|
||||
IDR_NEW_BRAVE_REWARDS_PAGE_HTML);
|
||||
|
||||
// Adaptive captcha challenges are displayed in an iframe on the Rewards
|
||||
|
||||
@@ -170,10 +170,11 @@ RewardsPanelUI::RewardsPanelUI(content::WebUI* web_ui)
|
||||
web_ui->GetWebContents()->GetBrowserContext(), kBraveRewardsPanelHost);
|
||||
source->AddLocalizedStrings(kStrings);
|
||||
|
||||
webui::SetupWebUIDataSource(source,
|
||||
base::make_span(kBraveRewardsPanelGenerated,
|
||||
kBraveRewardsPanelGeneratedSize),
|
||||
IDR_BRAVE_REWARDS_PANEL_HTML);
|
||||
webui::SetupWebUIDataSource(
|
||||
source,
|
||||
UNSAFE_TODO(base::make_span(kBraveRewardsPanelGenerated,
|
||||
kBraveRewardsPanelGeneratedSize)),
|
||||
IDR_BRAVE_REWARDS_PANEL_HTML);
|
||||
|
||||
// Adaptive captcha challenges are displayed in an iframe on the Rewards
|
||||
// panel. In order to display these challenges we need to specify in CSP that
|
||||
|
||||
@@ -80,7 +80,8 @@ TipPanelUI::TipPanelUI(content::WebUI* web_ui)
|
||||
source->AddLocalizedStrings(kStrings);
|
||||
|
||||
webui::SetupWebUIDataSource(
|
||||
source, base::make_span(kTipPanelGenerated, kTipPanelGeneratedSize),
|
||||
source,
|
||||
UNSAFE_TODO(base::make_span(kTipPanelGenerated, kTipPanelGeneratedSize)),
|
||||
IDR_TIP_PANEL_HTML);
|
||||
|
||||
source->OverrideContentSecurityPolicy(
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/browser/ui/webui/brave_settings_ui.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -49,7 +49,8 @@ CookieListOptInUI::CookieListOptInUI(content::WebUI* web_ui)
|
||||
|
||||
webui::SetupWebUIDataSource(
|
||||
source,
|
||||
base::make_span(kCookieListOptInGenerated, kCookieListOptInGeneratedSize),
|
||||
UNSAFE_TODO(base::make_span(kCookieListOptInGenerated,
|
||||
kCookieListOptInGeneratedSize)),
|
||||
IDR_COOKIE_LIST_OPT_IN_HTML);
|
||||
|
||||
content::URLDataSource::Add(
|
||||
|
||||
@@ -70,10 +70,11 @@ ShieldsPanelUI::ShieldsPanelUI(content::WebUI* web_ui)
|
||||
profile_, std::make_unique<FaviconSource>(
|
||||
profile_, chrome::FaviconUrlFormat::kFavicon2));
|
||||
|
||||
webui::SetupWebUIDataSource(source,
|
||||
base::make_span(kBraveShieldsPanelGenerated,
|
||||
kBraveShieldsPanelGeneratedSize),
|
||||
IDR_SHIELDS_PANEL_HTML);
|
||||
webui::SetupWebUIDataSource(
|
||||
source,
|
||||
UNSAFE_TODO(base::make_span(kBraveShieldsPanelGenerated,
|
||||
kBraveShieldsPanelGeneratedSize)),
|
||||
IDR_SHIELDS_PANEL_HTML);
|
||||
}
|
||||
|
||||
ShieldsPanelUI::~ShieldsPanelUI() = default;
|
||||
|
||||
@@ -43,7 +43,8 @@ VPNPanelUI::VPNPanelUI(content::WebUI* web_ui)
|
||||
brave_vpn::AddLocalizedStrings(source);
|
||||
webui::SetupWebUIDataSource(
|
||||
source,
|
||||
base::make_span(kBraveVpnPanelGenerated, kBraveVpnPanelGeneratedSize),
|
||||
UNSAFE_TODO(base::make_span(kBraveVpnPanelGenerated,
|
||||
kBraveVpnPanelGeneratedSize)),
|
||||
IDR_VPN_PANEL_HTML);
|
||||
|
||||
source->OverrideContentSecurityPolicy(
|
||||
|
||||
@@ -52,10 +52,11 @@ AndroidWalletPageUI::AndroidWalletPageUI(content::WebUI* web_ui,
|
||||
|
||||
// Add required resources.
|
||||
if (url.host() == kWalletPageHost) {
|
||||
webui::SetupWebUIDataSource(source,
|
||||
base::make_span(kBraveWalletPageGenerated,
|
||||
kBraveWalletPageGeneratedSize),
|
||||
IDR_WALLET_PAGE_HTML);
|
||||
webui::SetupWebUIDataSource(
|
||||
source,
|
||||
UNSAFE_TODO(base::make_span(kBraveWalletPageGenerated,
|
||||
kBraveWalletPageGeneratedSize)),
|
||||
IDR_WALLET_PAGE_HTML);
|
||||
} else {
|
||||
NOTREACHED_IN_MIGRATION()
|
||||
<< "Failed to find page resources for:" << url.path();
|
||||
|
||||
@@ -21,8 +21,8 @@ UntrustedLedgerUI::UntrustedLedgerUI(content::WebUI* web_ui)
|
||||
auto* untrusted_source = content::WebUIDataSource::CreateAndAdd(
|
||||
web_ui->GetWebContents()->GetBrowserContext(), kUntrustedLedgerURL);
|
||||
untrusted_source->SetDefaultResource(IDR_BRAVE_WALLET_LEDGER_BRIDGE_HTML);
|
||||
untrusted_source->AddResourcePaths(
|
||||
base::make_span(kLedgerBridgeGenerated, kLedgerBridgeGeneratedSize));
|
||||
untrusted_source->AddResourcePaths(UNSAFE_TODO(
|
||||
base::make_span(kLedgerBridgeGenerated, kLedgerBridgeGeneratedSize)));
|
||||
untrusted_source->AddFrameAncestor(GURL(kBraveUIWalletPageURL));
|
||||
untrusted_source->AddFrameAncestor(GURL(kBraveUIWalletPanelURL));
|
||||
untrusted_source->OverrideContentSecurityPolicy(
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/browser/ui/webui/brave_wallet/line_chart/line_chart_ui.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/browser/ui/webui/brave_wallet/market/market_ui.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/browser/ui/webui/brave_wallet/nft/nft_ui.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -25,8 +25,8 @@ UntrustedTrezorUI::UntrustedTrezorUI(content::WebUI* web_ui)
|
||||
auto* untrusted_source = content::WebUIDataSource::CreateAndAdd(
|
||||
web_ui->GetWebContents()->GetBrowserContext(), kUntrustedTrezorURL);
|
||||
untrusted_source->SetDefaultResource(IDR_BRAVE_WALLET_TREZOR_BRIDGE_HTML);
|
||||
untrusted_source->AddResourcePaths(
|
||||
base::make_span(kTrezorBridgeGenerated, kTrezorBridgeGeneratedSize));
|
||||
untrusted_source->AddResourcePaths(UNSAFE_TODO(
|
||||
base::make_span(kTrezorBridgeGenerated, kTrezorBridgeGeneratedSize)));
|
||||
untrusted_source->AddFrameAncestor(GURL(kBraveUIWalletPageURL));
|
||||
untrusted_source->AddFrameAncestor(GURL(kBraveUIWalletPanelURL));
|
||||
untrusted_source->OverrideContentSecurityPolicy(
|
||||
|
||||
@@ -65,7 +65,8 @@ WalletPageUI::WalletPageUI(content::WebUI* web_ui)
|
||||
NavigationBarDataProvider::Initialize(source, profile);
|
||||
webui::SetupWebUIDataSource(
|
||||
source,
|
||||
base::make_span(kBraveWalletPageGenerated, kBraveWalletPageGeneratedSize),
|
||||
UNSAFE_TODO(base::make_span(kBraveWalletPageGenerated,
|
||||
kBraveWalletPageGeneratedSize)),
|
||||
IDR_WALLET_PAGE_HTML);
|
||||
source->AddString("braveWalletLedgerBridgeUrl", kUntrustedLedgerURL);
|
||||
source->OverrideContentSecurityPolicy(
|
||||
|
||||
@@ -66,10 +66,11 @@ WalletPanelUI::WalletPanelUI(content::WebUI* web_ui)
|
||||
plural_string_handler->AddLocalizedString(
|
||||
"braveWalletPendingTransactions", IDS_BRAVE_WALLET_PENDING_TRANSACTIONS);
|
||||
web_ui->AddMessageHandler(std::move(plural_string_handler));
|
||||
webui::SetupWebUIDataSource(source,
|
||||
base::make_span(kBraveWalletPanelGenerated,
|
||||
kBraveWalletPanelGeneratedSize),
|
||||
IDR_WALLET_PANEL_HTML);
|
||||
webui::SetupWebUIDataSource(
|
||||
source,
|
||||
UNSAFE_TODO(base::make_span(kBraveWalletPanelGenerated,
|
||||
kBraveWalletPanelGeneratedSize)),
|
||||
IDR_WALLET_PANEL_HTML);
|
||||
source->AddString("braveWalletLedgerBridgeUrl", kUntrustedLedgerURL);
|
||||
source->OverrideContentSecurityPolicy(
|
||||
network::mojom::CSPDirectiveName::FrameSrc,
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/browser/ui/webui/brave_webui_source.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
@@ -32,7 +32,12 @@ async function updateUnsafeBuffersPaths() {
|
||||
...repoContent.split('\n'),
|
||||
'# Appended path correction for redirect_cc by update_patches.',
|
||||
'# File patched by brave/build/commands/lib/updateUnsafeBuffersPaths.js.',
|
||||
'-brave/'
|
||||
'-brave/third_party/bip39wally-core-native/',
|
||||
'-brave/third_party/argon2/',
|
||||
'-brave/third_party/ethash/',
|
||||
'-brave/third_party/bitcoin-core/',
|
||||
'-brave/third_party/rapidjson/',
|
||||
'-brave/vendor/bat-native-tweetnacl/'
|
||||
];
|
||||
|
||||
updatedPathLines = bufferPathLines.filter(
|
||||
|
||||
@@ -31,8 +31,9 @@ namespace extensions {
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < std::size(kAllowed); ++i) {
|
||||
if (extension_id == kAllowed[i])
|
||||
if (extension_id == UNSAFE_TODO(kAllowed[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return IsComponentExtensionAllowlisted_ChromiumImpl(extension_id);
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
|
||||
|
||||
#include "base/values.h"
|
||||
|
||||
@@ -69,7 +69,8 @@ void RecentTabsSubMenuModelTest::VerifyModel(
|
||||
item_data.enabled = false;
|
||||
}
|
||||
|
||||
::VerifyModel(model, base::make_span(v_data.begin(), v_data.size()));
|
||||
::VerifyModel(model,
|
||||
UNSAFE_TODO(base::make_span(v_data.begin(), v_data.size())));
|
||||
}
|
||||
|
||||
void RecentTabsSubMenuModelTest::VerifyModel(const ui::MenuModel* model,
|
||||
|
||||
@@ -40,9 +40,9 @@ std::vector<AcceleratorMapping> GetAcceleratorList() {
|
||||
std::vector<AcceleratorMapping> accelerator_list(
|
||||
GetAcceleratorList_ChromiumImpl());
|
||||
|
||||
accelerator_list.insert(
|
||||
UNSAFE_TODO(accelerator_list.insert(
|
||||
accelerator_list.end(), kBraveAcceleratorMap,
|
||||
kBraveAcceleratorMap + std::size(kBraveAcceleratorMap));
|
||||
kBraveAcceleratorMap + std::size(kBraveAcceleratorMap)));
|
||||
|
||||
return accelerator_list;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "chrome/install_static/install_modes.h"
|
||||
|
||||
#include <windows.h> // NOLINT
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include <objbase.h>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "build/branding_buildflags.h"
|
||||
|
||||
#define BRAVE_RUN_SETUP \
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/logging.h"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "components/search_engines/search_engine_utils.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "brave/components/search_engines/brave_prepopulated_engines.h"
|
||||
|
||||
#define GetEngineType GetEngineType_ChromiumImpl
|
||||
@@ -24,7 +25,7 @@ SearchEngineType GetEngineType(const GURL& url) {
|
||||
return engine->type;
|
||||
}
|
||||
for (size_t j = 0; j < engine->alternate_urls_size; ++j) {
|
||||
if (SameDomain(url, GURL(engine->alternate_urls[j]))) {
|
||||
if (SameDomain(url, UNSAFE_TODO(GURL(engine->alternate_urls[j])))) {
|
||||
return engine->type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/socket/socks5_client_socket.h"
|
||||
|
||||
@@ -112,9 +113,9 @@ int SOCKS5ClientSocketAuth::Authenticate(
|
||||
DCHECK_EQ(OK, rv);
|
||||
DCHECK_LT(0u, buffer_left_);
|
||||
iobuf_ = base::MakeRefCounted<IOBufferWithSize>(buffer_left_);
|
||||
memcpy(iobuf_->data(),
|
||||
&buffer_.data()[buffer_.size() - buffer_left_],
|
||||
buffer_left_);
|
||||
UNSAFE_TODO(memcpy(iobuf_->data(),
|
||||
&buffer_.data()[buffer_.size() - buffer_left_],
|
||||
buffer_left_));
|
||||
next_state_ = STATE_WRITE_COMPLETE;
|
||||
net_log.BeginEvent(NetLogEventType::SOCKS5_AUTH_WRITE);
|
||||
rv = transport_socket_->Write(iobuf_.get(), buffer_left_, callback,
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "src/sandbox/win/src/interceptors_64.cc"
|
||||
|
||||
#include "brave/sandbox/win/src/module_file_name_interception.h"
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "brave/third_party/blink/renderer/core/farbling/brave_session_cache.h"
|
||||
#include "third_party/blink/renderer/modules/mediastream/media_device_info.h"
|
||||
|
||||
@@ -26,7 +27,7 @@ void FarbleMediaDevices(ExecutionContext* context,
|
||||
FarblingPRNG prng =
|
||||
BraveSessionCache::From(*context).MakePseudoRandomGenerator();
|
||||
MediaDeviceInfoVector::iterator it_begin = media_devices->begin();
|
||||
std::shuffle(++it_begin, media_devices->end(), prng);
|
||||
UNSAFE_TODO(std::shuffle(++it_begin, media_devices->end(), prng));
|
||||
}
|
||||
|
||||
} // namespace brave
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "third_party/blink/renderer/modules/speech/speech_synthesis.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "brave/third_party/blink/renderer/brave_farbling_constants.h"
|
||||
#include "brave/third_party/blink/renderer/core/farbling/brave_session_cache.h"
|
||||
#include "third_party/blink/public/platform/web_content_settings_client.h"
|
||||
@@ -46,7 +47,8 @@ void SpeechSynthesis::OnSetVoiceList(
|
||||
"Wilson", "Alva", "Harley", "Beauregard", "Cleveland",
|
||||
"Cecil", "Reuben", "Sylvester", "Jasper"};
|
||||
const int kFakeNamesCount = std::size(kFakeNames);
|
||||
fake_voice->name = WTF::String(kFakeNames[prng() % kFakeNamesCount]);
|
||||
fake_voice->name =
|
||||
UNSAFE_TODO(WTF::String(kFakeNames[prng() % kFakeNamesCount]));
|
||||
}
|
||||
}
|
||||
voice_list_.push_back(
|
||||
|
||||
@@ -112,7 +112,7 @@ base::FilePath LocalModelsComponentInstallerPolicy::GetRelativeInstallDir()
|
||||
void LocalModelsComponentInstallerPolicy::GetHash(
|
||||
std::vector<uint8_t>* hash) const {
|
||||
hash->assign(kPublicKeySHA256,
|
||||
kPublicKeySHA256 + std::size(kPublicKeySHA256));
|
||||
UNSAFE_TODO(kPublicKeySHA256 + std::size(kPublicKeySHA256)));
|
||||
}
|
||||
|
||||
std::string LocalModelsComponentInstallerPolicy::GetName() const {
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/ai_chat/core/browser/text_embedder.h"
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/ai_chat/renderer/page_content_extractor.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -174,7 +174,7 @@ void DistillPageText(
|
||||
};
|
||||
|
||||
render_frame->GetWebFrame()->RequestExecuteScript(
|
||||
isolated_world_id, base::make_span(&source, 1u),
|
||||
isolated_world_id, UNSAFE_TODO(base::make_span(&source, 1u)),
|
||||
blink::mojom::UserActivationOption::kDoNotActivate,
|
||||
blink::mojom::EvaluationTiming::kAsynchronous,
|
||||
blink::mojom::LoadEventBlockingOption::kDoNotBlock,
|
||||
|
||||
+6
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/redeem_reward_confirmation.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_CALENDAR_CALENDAR_UTIL_H_
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
namespace base {
|
||||
class Time;
|
||||
@@ -29,7 +30,7 @@ constexpr int DaysInMonth(const int year, const int month) noexcept {
|
||||
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 // non leap year.
|
||||
};
|
||||
|
||||
int days_in_month = kDaysInMonth[month - 1];
|
||||
int days_in_month = UNSAFE_TODO(kDaysInMonth[month - 1]);
|
||||
if (month == /*february*/ 2 && IsLeapYear(year)) {
|
||||
// In a leap year, February gets an extra day, because even the shortest
|
||||
// month deserves a little extra time to shine!
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_ads/core/internal/common/calendar/calendar_util.h"
|
||||
|
||||
#include "base/time/time.h" // IWYU pragma: keep
|
||||
|
||||
@@ -101,8 +101,8 @@ TEST(BraveAdsCryptoUtilTest, EncryptAndDecrypt) {
|
||||
const KeyPairInfo key_pair = GenerateBoxKeyPair();
|
||||
const KeyPairInfo ephemeral_key_pair = GenerateBoxKeyPair();
|
||||
const std::vector<uint8_t> nonce = GenerateRandomNonce();
|
||||
const std::vector<uint8_t> plaintext(kMessage,
|
||||
kMessage + std::size(kMessage));
|
||||
const std::vector<uint8_t> plaintext(
|
||||
kMessage, UNSAFE_TODO(kMessage + std::size(kMessage)));
|
||||
|
||||
// Act
|
||||
const std::vector<uint8_t> ciphertext = Encrypt(
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ CreativeInlineContentAdList BuildCreativeInlineContentAds(const int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
CreativeInlineContentAdInfo creative_ad = BuildCreativeInlineContentAd(
|
||||
/*should_generate_random_uuids=*/true);
|
||||
creative_ad.segment = kSegments[i % std::size(kSegments)];
|
||||
creative_ad.segment = UNSAFE_TODO(kSegments[i % std::size(kSegments)]);
|
||||
|
||||
creative_ads.push_back(creative_ad);
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ CreativeNewTabPageAdList BuildCreativeNewTabPageAds(const int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
CreativeNewTabPageAdInfo creative_ad =
|
||||
BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/true);
|
||||
creative_ad.segment = kSegments[i % std::size(kSegments)];
|
||||
creative_ad.segment = UNSAFE_TODO(kSegments[i % std::size(kSegments)]);
|
||||
|
||||
creative_ads.push_back(creative_ad);
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ CreativeNotificationAdList BuildCreativeNotificationAds(const int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(
|
||||
/*should_generate_random_uuids=*/true);
|
||||
creative_ad.segment = kSegments[i % std::size(kSegments)];
|
||||
creative_ad.segment = UNSAFE_TODO(kSegments[i % std::size(kSegments)]);
|
||||
|
||||
creative_ads.push_back(creative_ad);
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ CreativePromotedContentAdList BuildCreativePromotedContentAds(const int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
CreativePromotedContentAdInfo creative_ad = BuildCreativePromotedContentAd(
|
||||
/*should_generate_random_uuids=*/true);
|
||||
creative_ad.segment = kSegments[i % std::size(kSegments)];
|
||||
creative_ad.segment = UNSAFE_TODO(kSegments[i % std::size(kSegments)]);
|
||||
|
||||
creative_ads.push_back(creative_ad);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_news/browser/feed_v2_builder.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -94,9 +94,10 @@ void InitializationPromise::OnGotLocale(const std::string& locale) {
|
||||
|
||||
// Determine how long we should wait based on the number of times we've
|
||||
// retried.
|
||||
int retry_delay = no_retry_delay_for_testing_
|
||||
? 0
|
||||
: kBackoffs[std::min(attempts_, kNumBackoffs - 1)];
|
||||
int retry_delay =
|
||||
no_retry_delay_for_testing_
|
||||
? 0
|
||||
: UNSAFE_TODO(kBackoffs[std::min(attempts_, kNumBackoffs - 1)]);
|
||||
base::SequencedTaskRunner::GetCurrentDefault()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&InitializationPromise::Initialize,
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_rewards/browser/diagnostic_log.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -210,7 +210,7 @@ std::string GetPrefPath(const std::string& name) {
|
||||
std::vector<std::string> GetISOCountries() {
|
||||
std::vector<std::string> countries;
|
||||
for (const char* const* country_pointer = icu::Locale::getISOCountries();
|
||||
*country_pointer; ++country_pointer) {
|
||||
*country_pointer; UNSAFE_TODO(++country_pointer)) {
|
||||
countries.emplace_back(*country_pointer);
|
||||
}
|
||||
return countries;
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_CORE_PUBLISHER_PREFIX_ITERATOR_H_
|
||||
#define BRAVE_COMPONENTS_BRAVE_REWARDS_CORE_PUBLISHER_PREFIX_ITERATOR_H_
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_shields/content/browser/brave_shields_p3a.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -119,7 +119,7 @@ base::FilePath AdBlockComponentInstallerPolicy::GetRelativeInstallDir() const {
|
||||
|
||||
void AdBlockComponentInstallerPolicy::GetHash(
|
||||
std::vector<uint8_t>* hash) const {
|
||||
hash->assign(component_hash_, component_hash_ + kHashSize);
|
||||
hash->assign(component_hash_, UNSAFE_TODO(component_hash_ + kHashSize));
|
||||
}
|
||||
|
||||
std::string AdBlockComponentInstallerPolicy::GetName() const {
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_sync/time_limited_words.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_vpn/browser/connection/ikev2/win/ras_utils.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_vpn/common/wireguard/wireguard_utils.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/bitcoin/bitcoin_discover_account_task.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/json/json_reader.h"
|
||||
@@ -543,8 +544,8 @@ void EnsResolverTask::OnFetchOffchainDone(APIRequestResult api_request_result) {
|
||||
offchain_lookup_attemps_left_--;
|
||||
DCHECK_GE(offchain_lookup_attemps_left_, 0);
|
||||
DCHECK_EQ(offchain_lookup_data_->callback_function.size(), 4u);
|
||||
eth_abi::Span4 callback_selector(
|
||||
offchain_lookup_data_->callback_function.begin(), 4u);
|
||||
UNSAFE_TODO(eth_abi::Span4 callback_selector(
|
||||
offchain_lookup_data_->callback_function.begin(), 4u));
|
||||
|
||||
offchain_callback_call_ = eth_abi::TupleEncoder()
|
||||
.AddBytes(*bytes_result)
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/eth_abi_decoder.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/eth_gas_utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/ethereum_keyring.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/internal/hd_key.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/meld_integration_response_parser.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/permission_utils.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/browser/solana_instruction_builder.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/values.h"
|
||||
@@ -120,8 +121,9 @@ base::FilePath WalletDataFilesInstallerPolicy::GetRelativeInstallDir() const {
|
||||
}
|
||||
|
||||
void WalletDataFilesInstallerPolicy::GetHash(std::vector<uint8_t>* hash) const {
|
||||
hash->assign(kWalletDataFilesSha2Hash,
|
||||
kWalletDataFilesSha2Hash + std::size(kWalletDataFilesSha2Hash));
|
||||
UNSAFE_TODO(hash->assign(
|
||||
kWalletDataFilesSha2Hash,
|
||||
kWalletDataFilesSha2Hash + std::size(kWalletDataFilesSha2Hash)));
|
||||
}
|
||||
|
||||
std::string WalletDataFilesInstallerPolicy::GetName() const {
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
|
||||
#include "brave/components/brave_wallet/common/btc_like_serializer_stream.h"
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/containers/span.h"
|
||||
#include "base/numerics/byte_conversions.h"
|
||||
|
||||
namespace brave_wallet {
|
||||
|
||||
void BtcLikeSerializerStream::Push8AsLE(uint8_t i) {
|
||||
base::span<uint8_t> data_to_insert(reinterpret_cast<uint8_t*>(&i), sizeof(i));
|
||||
UNSAFE_TODO(base::span<uint8_t> data_to_insert(reinterpret_cast<uint8_t*>(&i),
|
||||
sizeof(i)));
|
||||
PushBytes(data_to_insert);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ std::optional<Span32> ToSpan32(Span data) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return Span32(data.data(), kRowLength);
|
||||
return UNSAFE_TODO(Span32(data.data(), kRowLength));
|
||||
}
|
||||
|
||||
Span ExtractRows(Span data, size_t row, size_t row_count) {
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/common/eth_abi_utils.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/common/eth_address.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
@@ -402,8 +403,8 @@ bool ParseEthDecryptParams(const std::string& json,
|
||||
}
|
||||
|
||||
// IsValidHexString guarantees at least 2 bytes and starts with 0x
|
||||
if (!base::HexStringToString(untrusted_hex_json_str->data() + 2,
|
||||
&untrusted_json)) {
|
||||
if (!UNSAFE_TODO(base::HexStringToString(untrusted_hex_json_str->data() + 2,
|
||||
&untrusted_json))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/brave_wallet/common/eth_sign_typed_data_helper.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <array>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/containers/adapters.h"
|
||||
#include "base/containers/span.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
@@ -39,7 +40,7 @@ std::string KeccakHash(const std::string& input, bool to_hex) {
|
||||
|
||||
std::vector<uint8_t> KeccakHash(const std::vector<uint8_t>& input) {
|
||||
auto hash = ethash_keccak256(input.data(), input.size());
|
||||
return std::vector<uint8_t>(hash.bytes, hash.bytes + 32);
|
||||
return UNSAFE_TODO(std::vector<uint8_t>(hash.bytes, hash.bytes + 32));
|
||||
}
|
||||
|
||||
eth_abi::Bytes32 KeccakHashBytes32(base::span<const uint8_t> input) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
@@ -156,7 +157,7 @@ std::string Uint256ValueToHex(uint256_t input) {
|
||||
static constexpr char kHexChars[] = "0123456789abcdef";
|
||||
while (input) {
|
||||
uint8_t i = static_cast<uint8_t>(input & static_cast<uint256_t>(0x0F));
|
||||
result.insert(result.begin(), kHexChars[i]);
|
||||
UNSAFE_TODO(result.insert(result.begin(), kHexChars[i]));
|
||||
input >>= 4;
|
||||
}
|
||||
if (result.empty()) {
|
||||
|
||||
@@ -115,7 +115,7 @@ bool JSSolanaProvider::V8ConverterStrategy::FromV8ArrayBuffer(
|
||||
if (gin::ConvertFromV8(isolate, value.As<v8::ArrayBufferView>(), &view)) {
|
||||
data = reinterpret_cast<char*>(view.bytes());
|
||||
data_length = view.num_bytes();
|
||||
bytes.assign(data, data + data_length);
|
||||
UNSAFE_TODO(bytes.assign(data, data + data_length));
|
||||
}
|
||||
if (!bytes.size()) {
|
||||
return false;
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ base::FilePath NTPBackgroundImagesComponentInstallerPolicy::
|
||||
|
||||
void NTPBackgroundImagesComponentInstallerPolicy::GetHash(
|
||||
std::vector<uint8_t>* hash) const {
|
||||
hash->assign(component_hash_, component_hash_ + kHashSize);
|
||||
hash->assign(component_hash_, UNSAFE_TODO(component_hash_ + kHashSize));
|
||||
}
|
||||
|
||||
std::string NTPBackgroundImagesComponentInstallerPolicy::GetName() const {
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/omnibox/browser/brave_search_provider.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/strcat.h"
|
||||
@@ -45,7 +46,7 @@ double GetHashProb(const std::string& query) {
|
||||
const auto b = query[i + 1];
|
||||
const auto pos1 = GetPosForHashChars(a);
|
||||
const auto pos2 = GetPosForHashChars(b);
|
||||
log_prob += kProbHashLogM[pos1][pos2];
|
||||
log_prob += UNSAFE_TODO(kProbHashLogM[pos1][pos2]);
|
||||
trans_c += 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/p3a/nitro_utils/attestation.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/p3a/nitro_utils/cose.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "components/permissions/permissions_client.h"
|
||||
#include "components/content_settings/core/common/content_settings_types.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@@ -125,7 +125,7 @@ base::FilePath MediaDetectorComponentInstallerPolicy::GetRelativeInstallDir()
|
||||
|
||||
void MediaDetectorComponentInstallerPolicy::GetHash(
|
||||
std::vector<uint8_t>* hash) const {
|
||||
hash->assign(component_hash_, component_hash_ + kHashSize);
|
||||
hash->assign(component_hash_, UNSAFE_TODO(component_hash_ + kHashSize));
|
||||
}
|
||||
|
||||
std::string MediaDetectorComponentInstallerPolicy::GetName() const {
|
||||
|
||||
@@ -202,8 +202,8 @@ void PlaylistThumbnailDownloader::WriteToFile(
|
||||
|
||||
auto write_to_file = base::BindOnce(
|
||||
[](base::FilePath path, scoped_refptr<base::RefCountedBytes> image) {
|
||||
if (!base::WriteFile(path, base::span<const uint8_t>(image->front(),
|
||||
image->size()))) {
|
||||
if (!base::WriteFile(path, UNSAFE_TODO(base::span<const uint8_t>(
|
||||
image->front(), image->size())))) {
|
||||
DVLOG(2) << "Failed to write image to file " << path;
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ base::FilePath PsstComponentInstallerPolicy::GetRelativeInstallDir() const {
|
||||
}
|
||||
|
||||
void PsstComponentInstallerPolicy::GetHash(std::vector<uint8_t>* hash) const {
|
||||
hash->assign(component_hash_, component_hash_ + kHashSize);
|
||||
hash->assign(component_hash_, UNSAFE_TODO(component_hash_ + kHashSize));
|
||||
}
|
||||
|
||||
std::string PsstComponentInstallerPolicy::GetName() const {
|
||||
|
||||
@@ -59,8 +59,8 @@ void ScriptInjectorRenderFrameObserver::RequestAsyncExecuteScript(
|
||||
auto want_result = CheckIfWantResult(callback);
|
||||
|
||||
render_frame()->GetWebFrame()->RequestExecuteScript(
|
||||
world_id, base::make_span(&web_script_source, 1u), user_activation,
|
||||
blink::mojom::EvaluationTiming::kAsynchronous,
|
||||
world_id, UNSAFE_TODO(base::make_span(&web_script_source, 1u)),
|
||||
user_activation, blink::mojom::EvaluationTiming::kAsynchronous,
|
||||
blink::mojom::LoadEventBlockingOption::kDoNotBlock,
|
||||
base::BindOnce(
|
||||
[](RequestAsyncExecuteScriptCallback callback,
|
||||
|
||||
@@ -489,7 +489,7 @@ TEST_F(BraveSyncServiceImplTest, OnAccountDeleted_FailureAndRetry) {
|
||||
&on_account_deleted_invoked),
|
||||
sync_protocol_error);
|
||||
|
||||
EXPECT_EQ(on_account_deleted_invoked, was_callback_invoked[i]);
|
||||
EXPECT_EQ(on_account_deleted_invoked, UNSAFE_TODO(was_callback_invoked[i]));
|
||||
}
|
||||
|
||||
OSCryptMocker::TearDown();
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/tor/tor_control.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef UNSAFE_BUFFERS_BUILD
|
||||
// TODO(https://github.com/brave/brave-browser/issues/41661): Remove this and
|
||||
// convert code to safer constructs.
|
||||
#pragma allow_unsafe_buffers
|
||||
#endif
|
||||
|
||||
#include "brave/components/tor/tor_control.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user