From 4646a88a2c3ed5eed21ea6a39630092b384a8c9b Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Tue, 4 Apr 2023 12:22:48 -0700 Subject: [PATCH] Trap and report error when hostname is null/empty Fixes https://github.com/brave/brave-browser/issues/28940 Fixes https://github.com/brave/brave-browser/issues/29502 Fixes https://github.com/brave/brave-browser/issues/29477 --- components/brave_vpn/browser/connection/win/utils.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/brave_vpn/browser/connection/win/utils.cc b/components/brave_vpn/browser/connection/win/utils.cc index 37c4bf5d04b8..17db0fe9b7be 100644 --- a/components/brave_vpn/browser/connection/win/utils.cc +++ b/components/brave_vpn/browser/connection/win/utils.cc @@ -329,6 +329,14 @@ RasOperationResult CreateEntry(const std::wstring& entry_name, const std::wstring& hostname, const std::wstring& username, const std::wstring& password) { + // `RasSetEntryProperties` can have problems if fields are empty. + // Specifically, it will crash if `hostname` is NULL. Entry name + // is already validated. + if (hostname.empty()) { + VLOG(2) << __func__ << " Can't create entry with empty `hostname`"; + return GetRasErrorResult("`hostname` is empty"); + } + auto connection_result = CheckConnection(entry_name); if (connection_result == CheckConnectionResult::CONNECTING || connection_result == CheckConnectionResult::CONNECTED) {