Skip to content

Commit

Permalink
Fixes smartcard cancel regression (#38805)
Browse files Browse the repository at this point in the history
During the IronRDP refactor the smartcard cancel functionality was
broken by forgetting to always return a response for the `SCARD_IOCTL_CANCEL`
request itself, along with the response for the cancelled `SCARD_IOCTL_GETSTATUSCHANGEW`.
This commit fixes that.
  • Loading branch information
ibeckermayer committed Feb 29, 2024
1 parent b3803b3 commit 7a1f09c
Showing 1 changed file with 13 additions and 8 deletions.
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

0 comments on commit 7a1f09c

Please sign in to comment.