UINT32 cReaders, UINT32* ptrIndex)
{
UINT32 index, len;
- LONG status = ERROR_INVALID_DATA;
+ LONG status = SCARD_E_NO_MEMORY;
LPSCARD_READERSTATEA rgReaderStates;
+ BOOL* states;
if (Stream_GetRemainingLength(s) < 4)
return status;
return status;
}
rgReaderStates = (LPSCARD_READERSTATEA)calloc(cReaders, sizeof(SCARD_READERSTATEA));
-
- if (!rgReaderStates)
- return STATUS_NO_MEMORY;
+ states = calloc(cReaders, sizeof(BOOL));
+ if (!rgReaderStates || !states)
+ goto fail;
+ status = ERROR_INVALID_DATA;
for (index = 0; index < cReaders; index++)
{
+ UINT32 ptr = UINT32_MAX;
LPSCARD_READERSTATEA readerState = &rgReaderStates[index];
if (Stream_GetRemainingLength(s) < 52)
goto fail;
}
- if (!smartcard_ndr_pointer_read(s, ptrIndex, NULL))
- goto fail;
+ if (!smartcard_ndr_pointer_read(s, ptrIndex, &ptr))
+ {
+ if (ptr != 0)
+ goto fail;
+ }
+ /* Ignore NULL length strings */
+ states[index] = ptr != 0;
Stream_Read_UINT32(s, readerState->dwCurrentState); /* dwCurrentState (4 bytes) */
Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
{
LPSCARD_READERSTATEA readerState = &rgReaderStates[index];
+ /* Ignore empty strings */
+ if (!states[index])
+ continue;
status = smartcard_ndr_read_a(s, &readerState->szReader, NDR_PTR_FULL);
if (status != SCARD_S_SUCCESS)
goto fail;
}
*ppcReaders = rgReaderStates;
+ free(states);
return SCARD_S_SUCCESS;
fail:
if (rgReaderStates)
}
}
free(rgReaderStates);
+ free(states);
return status;
}
UINT32 cReaders, UINT32* ptrIndex)
{
UINT32 index, len;
- LONG status = ERROR_INVALID_DATA;
+ LONG status = SCARD_E_NO_MEMORY;
LPSCARD_READERSTATEW rgReaderStates;
+ BOOL* states;
if (Stream_GetRemainingLength(s) < 4)
return status;
}
rgReaderStates = (LPSCARD_READERSTATEW)calloc(cReaders, sizeof(SCARD_READERSTATEW));
+ states = calloc(cReaders, sizeof(BOOL));
- if (!rgReaderStates)
- return STATUS_NO_MEMORY;
+ if (!rgReaderStates || !states)
+ goto fail;
+ status = ERROR_INVALID_DATA;
for (index = 0; index < cReaders; index++)
{
+ UINT32 ptr = UINT32_MAX;
LPSCARD_READERSTATEW readerState = &rgReaderStates[index];
if (Stream_GetRemainingLength(s) < 52)
goto fail;
}
- if (!smartcard_ndr_pointer_read(s, ptrIndex, NULL))
- goto fail;
+ if (!smartcard_ndr_pointer_read(s, ptrIndex, &ptr))
+ {
+ if (ptr != 0)
+ goto fail;
+ }
+ /* Ignore NULL length strings */
+ states[index] = ptr != 0;
Stream_Read_UINT32(s, readerState->dwCurrentState); /* dwCurrentState (4 bytes) */
Stream_Read_UINT32(s, readerState->dwEventState); /* dwEventState (4 bytes) */
Stream_Read_UINT32(s, readerState->cbAtr); /* cbAtr (4 bytes) */
{
LPSCARD_READERSTATEW readerState = &rgReaderStates[index];
+ /* Skip NULL pointers */
+ if (!states[index])
+ continue;
+
status = smartcard_ndr_read_w(s, &readerState->szReader, NDR_PTR_FULL);
if (status != SCARD_S_SUCCESS)
goto fail;
}
*ppcReaders = rgReaderStates;
+ free(states);
return SCARD_S_SUCCESS;
fail:
if (rgReaderStates)
}
}
free(rgReaderStates);
+ free(states);
return status;
}