-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi,
There are a few issues with this. They seem vaguely familiar to me, I think I have raised them before but they got lost in the list to array conversion:
On 04/15/15 12:07, Alistair Leslie-Hughes wrote:
@@ -405,9 +405,48 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Ad const DWORD dwComponentID, WCHAR *pwszName, DWORD *pdwNameLen, void *pvBuffer, DWORD *pdwBufferSize, DWORD *pdwDataType) {
I assume you're supposed to write the name to pwszName if it is non-NULL, and check *pdwNameLen against the string length first.
- entry = This->components[dwComponentID];
- if(*pdwBufferSize < entry->size)
- {
*pdwBufferSize = entry->size;
return DPNERR_BUFFERTOOSMALL;
- }
It seems to me that it should assign *pdwDataType and *pdwNameLen in this case. The test should be extended to explicitly check the assigned lengths. Your code never sets *pdwNameLen, and it sets *pdwDataType only if the buffer is big enough.
The concern about assigning *pdwDataType in the buffer to small case also applies to GetComponentByName.
- switch (entry->type)
- {
case DPNA_DATATYPE_DWORD:
memcpy(pvBuffer, &entry->data.value, sizeof(DWORD));
break;
case DPNA_DATATYPE_GUID:
memcpy(pvBuffer, &entry->data.guid, sizeof(GUID));
break;
Assignments should be enough in these cases. The same applies to the existing GetComponentByName code.
A semi-related problem in the existing GetComponentByName code:
if(!pwszName || !pdwBufferSize || !pdwDataType || (!pvBuffer && pdwBufferSize)) return E_POINTER;
The second check for pdwBufferSize is redundant, you already established it is not NULL. I assume that's supposed to be *pdwBufferSize.