Commit bc3738b8 authored by Martin Kreichgauer's avatar Martin Kreichgauer Committed by Commit Bot

fido: fix a crash when setting security key PINs from Settings

In CL:2350026, I tried to be clever and eliminate the unused
FidoDiscoveryFactory argument from SetPINHandler. However, its base
FidoRequestHandlerBase ctor expects a pointer to the discovery factory
and is run before initialization of the SetPINHandler data members, and
so we now pass it the address of an uninitialized member.  Instead,
inject the FidoDiscoveryFactory from the outside, like before.

Bug: 1122892
Change-Id: I8ea881c57c9dc2b3c33c1bda2f0512459f3a7c47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2384133Reviewed-by: default avatarAdam Langley <agl@chromium.org>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#803148}
parent 296aba8e
......@@ -17,10 +17,13 @@ namespace device {
SetPINRequestHandler::SetPINRequestHandler(
const base::flat_set<FidoTransportProtocol>& supported_transports,
GetPINCallback get_pin_callback,
FinishedCallback finished_callback)
: FidoRequestHandlerBase(&fido_discovery_factory_, supported_transports),
FinishedCallback finished_callback,
std::unique_ptr<FidoDiscoveryFactory> fido_discovery_factory)
: FidoRequestHandlerBase(fido_discovery_factory.get(),
supported_transports),
get_pin_callback_(std::move(get_pin_callback)),
finished_callback_(std::move(finished_callback)) {
finished_callback_(std::move(finished_callback)),
fido_discovery_factory_(std::move(fido_discovery_factory)) {
Start();
}
......
......@@ -57,7 +57,9 @@ class COMPONENT_EXPORT(DEVICE_FIDO) SetPINRequestHandler
SetPINRequestHandler(
const base::flat_set<FidoTransportProtocol>& supported_transports,
GetPINCallback get_pin_callback,
FinishedCallback finished_callback);
FinishedCallback finished_callback,
std::unique_ptr<FidoDiscoveryFactory> fido_discovery_factory =
std::make_unique<FidoDiscoveryFactory>());
~SetPINRequestHandler() override;
// ProvidePIN may be called after |get_pin_callback| has been used to indicate
......@@ -95,7 +97,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) SetPINRequestHandler
// The pointed-at object is owned by the |FidoRequestHandlerBase| superclass
// of this class.
FidoAuthenticator* authenticator_ = nullptr;
FidoDiscoveryFactory fido_discovery_factory_;
std::unique_ptr<FidoDiscoveryFactory> fido_discovery_factory_;
SEQUENCE_CHECKER(my_sequence_checker_);
base::WeakPtrFactory<SetPINRequestHandler> weak_factory_{this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment