Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v15] Fixes smartcard cancel regression #38805

Merged
merged 1 commit into from Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/srv/desktop/rdp/rdpclient/src/rdpdr/scard.rs
Expand Up @@ -406,18 +406,22 @@ impl ScardBackend {
req: DeviceControlRequest<ScardIoCtlCode>,
call: ContextCall,
) -> PduResult<()> {
let resp = self
debug!(
"received SCARD_IOCTL_CANCEL for context [{}]",
call.context.value
);
if let Some(resp) = self
.contexts
.take_scard_cancel_response(call.context.value)?;
if let Some(resp) = resp {
.take_scard_cancel_response(call.context.value)?
{
// Take the pending SCARD_IOCTL_GETSTATUSCHANGEW response and send it back to the server.
self.client_handle.write_rdpdr(resp.into())?;
Ok(())
} else {
// TODO: Currently we're just returning ReturnCode::Success here (based on awly's pre-
// IronRDP code). Should we instead be returning SCARD_E_CANCELLED (or something else)?
warn!("Received SCARD_IOCTL_CANCEL for a context without a pending SCARD_IOCTL_GETSTATUSCHANGEW");
self.send_device_control_response(req, LongReturn::new(ReturnCode::Success))
}
};

// Also return a response for the SCARD_IOCTL_CANCEL request itself.
self.send_device_control_response(req, LongReturn::new(ReturnCode::Success))
}

fn handle_is_valid_context(
Expand Down Expand Up @@ -549,6 +553,7 @@ impl Contexts {
}

fn set_scard_cancel_response(&mut self, id: u32, resp: DeviceControlResponse) -> PduResult<()> {
debug!("setting SCARD_IOCTL_CANCEL response for context [{}]", id);
self.get_internal_mut(id)?.set_scard_cancel_response(resp)
}

Expand Down