fix channel/smartcard: simplify channel variables

Path was not really used and name was duplicated. Use the device->Name
directly.
This commit is contained in:
Bernhard Miklautz 2017-12-11 14:00:09 +01:00
parent 6e63c6afd9
commit 1e6fea7fa7
6 changed files with 19 additions and 64 deletions

View File

@ -677,17 +677,12 @@ static UINT smartcard_irp_request(DEVICE* device, IRP* irp)
*/
UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
size_t length;
int ck;
RDPDR_SMARTCARD* device;
SMARTCARD_DEVICE* smartcard;
LONG status;
UINT error = CHANNEL_RC_NO_MEMORY;
device = (RDPDR_SMARTCARD*) pEntryPoints->device;
name = device->Name;
path = device->Path;
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
if (!smartcard)
@ -712,23 +707,8 @@ UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
}
Stream_Write(smartcard->device.data, "SCARD", 6);
smartcard->name = NULL;
smartcard->path = NULL;
if (path)
{
smartcard->path = path;
smartcard->name = name;
}
else if (name)
{
if (1 == sscanf(name, "%d", &ck))
smartcard->path = name;
else
smartcard->name = name;
}
status = SCardAddReaderName(&smartcard->thread, (LPSTR) name);
status = SCardAddReaderName(&smartcard->thread, (LPSTR) device->Name);
if (status != SCARD_S_SUCCESS)
{

View File

@ -110,9 +110,6 @@ struct _SMARTCARD_DEVICE
{
DEVICE device;
char* name;
char* path;
HANDLE thread;
HANDLE StartedEvent;
wMessageQueue* IrpQueue;

View File

@ -850,7 +850,7 @@ void smartcard_trace_list_readers_return(SMARTCARD_DEVICE* smartcard, ListReader
CopyMemory(mszA, ret->msz, ret->cBytes);
}
for (index = 0; index < length - 2; index++)
for (index = 0; index < length - 1; index++)
{
if (mszA[index] == '\0')
mszA[index] = ',';

View File

@ -476,43 +476,29 @@ BOOL freerdp_client_add_device_channel(rdpSettings* settings, int count,
settings->RedirectSmartCards = TRUE;
settings->DeviceRedirection = TRUE;
if (count > 1)
smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
if (!smartcard)
return FALSE;
smartcard->Type = RDPDR_DTYP_SMARTCARD;
if (count > 1 && strlen(params[1]))
{
smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
if (!smartcard)
return FALSE;
smartcard->Type = RDPDR_DTYP_SMARTCARD;
if (count > 1)
if (!(smartcard->Name = _strdup(params[1])))
{
if (!(smartcard->Name = _strdup(params[1])))
{
free(smartcard);
return FALSE;
}
}
if (count > 2)
{
if (!(smartcard->Path = _strdup(params[2])))
{
free(smartcard->Name);
free(smartcard);
return FALSE;
}
}
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard))
{
free(smartcard->Path);
free(smartcard->Name);
free(smartcard);
return FALSE;
}
}
if (!freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard))
{
free(smartcard->Name);
free(smartcard);
return FALSE;
}
return TRUE;
}
else if (strcmp(params[0], "serial") == 0)

View File

@ -446,7 +446,6 @@ struct _RDPDR_SMARTCARD
UINT32 Id;
UINT32 Type;
char* Name;
char* Path;
};
typedef struct _RDPDR_SMARTCARD RDPDR_SMARTCARD;

View File

@ -307,13 +307,6 @@ out_print_name_error:
goto out_smartc_name_error;
}
if (smartcard->Path)
{
_smartcard->Path = _strdup(smartcard->Path);
if (!_smartcard->Path)
goto out_smartc_path_error;
}
return (RDPDR_DEVICE*) _smartcard;
out_smartc_path_error:
@ -428,7 +421,7 @@ void freerdp_device_collection_free(rdpSettings* settings)
}
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_SMARTCARD)
{
free(((RDPDR_SMARTCARD*) device)->Path);
}
else if (settings->DeviceArray[index]->Type == RDPDR_DTYP_SERIAL)
{