advapi32: RegGetValue() should not return an error when expanding a string and given a NULL buffer and a zero size.
Adjust the tests to cover this case for REG_EXPAND_SZ registry values. Improve the documentation a bit.
This commit is contained in:
parent
9bccd06bf9
commit
c47c6483aa
@ -1417,8 +1417,8 @@ static VOID ADVAPI_ApplyRestrictions( DWORD dwFlags, DWORD dwType,
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* RegGetValueW [ADVAPI32.@]
|
* RegGetValueW [ADVAPI32.@]
|
||||||
*
|
*
|
||||||
* Retrieves the type and data for a value name associated with a key
|
* Retrieves the type and data for a value name associated with a key,
|
||||||
* optionally expanding it's content and restricting it's type.
|
* optionally expanding its content and restricting its type.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* hKey [I] Handle to an open key.
|
* hKey [I] Handle to an open key.
|
||||||
@ -1427,16 +1427,17 @@ static VOID ADVAPI_ApplyRestrictions( DWORD dwFlags, DWORD dwType,
|
|||||||
* dwFlags [I] Flags restricting the value type to retrieve.
|
* dwFlags [I] Flags restricting the value type to retrieve.
|
||||||
* pdwType [O] Destination for the values type, may be NULL.
|
* pdwType [O] Destination for the values type, may be NULL.
|
||||||
* pvData [O] Destination for the values content, may be NULL.
|
* pvData [O] Destination for the values content, may be NULL.
|
||||||
* pcbData [I/O] Size of pvData, updated with the size required to
|
* pcbData [I/O] Size of pvData, updated with the size in bytes required to
|
||||||
* retrieve the whole content.
|
* retrieve the whole content, including the trailing '\0'
|
||||||
|
* for strings.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: ERROR_SUCCESS
|
* Success: ERROR_SUCCESS
|
||||||
* Failure: nonzero error code from Winerror.h
|
* Failure: nonzero error code from Winerror.h
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* - Unless RRF_NOEXPAND is specified REG_EXPAND_SZ is automatically expanded
|
* - Unless RRF_NOEXPAND is specified, REG_EXPAND_SZ values are automatically
|
||||||
* and REG_SZ is retrieved instead.
|
* expanded and pdwType is set to REG_SZ instead.
|
||||||
* - Restrictions are applied after expanding, using RRF_RT_REG_EXPAND_SZ
|
* - Restrictions are applied after expanding, using RRF_RT_REG_EXPAND_SZ
|
||||||
* without RRF_NOEXPAND is thus not allowed.
|
* without RRF_NOEXPAND is thus not allowed.
|
||||||
*/
|
*/
|
||||||
@ -1505,7 +1506,7 @@ LSTATUS WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue,
|
|||||||
cbData = ExpandEnvironmentStringsW(pvBuf, pvData,
|
cbData = ExpandEnvironmentStringsW(pvBuf, pvData,
|
||||||
pcbData ? *pcbData : 0);
|
pcbData ? *pcbData : 0);
|
||||||
dwType = REG_SZ;
|
dwType = REG_SZ;
|
||||||
if(pcbData && cbData > *pcbData)
|
if(pvData && pcbData && cbData > *pcbData)
|
||||||
ret = ERROR_MORE_DATA;
|
ret = ERROR_MORE_DATA;
|
||||||
}
|
}
|
||||||
else if (pvData)
|
else if (pvData)
|
||||||
@ -1600,7 +1601,7 @@ LSTATUS WINAPI RegGetValueA( HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue,
|
|||||||
cbData = ExpandEnvironmentStringsA(pvBuf, pvData,
|
cbData = ExpandEnvironmentStringsA(pvBuf, pvData,
|
||||||
pcbData ? *pcbData : 0);
|
pcbData ? *pcbData : 0);
|
||||||
dwType = REG_SZ;
|
dwType = REG_SZ;
|
||||||
if(pcbData && cbData > *pcbData)
|
if(pvData && pcbData && cbData > *pcbData)
|
||||||
ret = ERROR_MORE_DATA;
|
ret = ERROR_MORE_DATA;
|
||||||
}
|
}
|
||||||
else if (pvData)
|
else if (pvData)
|
||||||
|
@ -710,7 +710,7 @@ static void test_get_value(void)
|
|||||||
ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf);
|
ok(!strcmp(sTestpath1, buf), "sTestpath=\"%s\" buf=\"%s\"\n", sTestpath1, buf);
|
||||||
|
|
||||||
/* Query REG_EXPAND_SZ using RRF_RT_REG_SZ and no buffer (ok, expands) */
|
/* Query REG_EXPAND_SZ using RRF_RT_REG_SZ and no buffer (ok, expands) */
|
||||||
size = 0xbadbeef;
|
size = 0;
|
||||||
ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_SZ, NULL, NULL, &size);
|
ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_SZ, NULL, NULL, &size);
|
||||||
ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
|
ok(ret == ERROR_SUCCESS, "ret=%d\n", ret);
|
||||||
/* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
|
/* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user