Module: wine Branch: master Commit: c47c6483aa680b94ec0d9c4acc9b50b26c0b771c URL: http://source.winehq.org/git/wine.git/?a=commit;h=c47c6483aa680b94ec0d9c4acc...
Author: Francois Gouget fgouget@codeweavers.com Date: Fri Jan 11 09:49:48 2008 +0100
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.
---
dlls/advapi32/registry.c | 17 +++++++++-------- dlls/advapi32/tests/registry.c | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c index d7f6dc4..dec2e4a 100644 --- a/dlls/advapi32/registry.c +++ b/dlls/advapi32/registry.c @@ -1417,8 +1417,8 @@ static VOID ADVAPI_ApplyRestrictions( DWORD dwFlags, DWORD dwType, /****************************************************************************** * RegGetValueW [ADVAPI32.@] * - * Retrieves the type and data for a value name associated with a key - * optionally expanding it's content and restricting it's type. + * Retrieves the type and data for a value name associated with a key, + * optionally expanding its content and restricting its type. * * PARAMS * 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. * pdwType [O] Destination for the values type, 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 - * retrieve the whole content. + * pcbData [I/O] Size of pvData, updated with the size in bytes required to + * retrieve the whole content, including the trailing '\0' + * for strings. * * RETURNS * Success: ERROR_SUCCESS * Failure: nonzero error code from Winerror.h * * NOTES - * - Unless RRF_NOEXPAND is specified REG_EXPAND_SZ is automatically expanded - * and REG_SZ is retrieved instead. + * - Unless RRF_NOEXPAND is specified, REG_EXPAND_SZ values are automatically + * expanded and pdwType is set to REG_SZ instead. * - Restrictions are applied after expanding, using RRF_RT_REG_EXPAND_SZ * without RRF_NOEXPAND is thus not allowed. */ @@ -1505,7 +1506,7 @@ LSTATUS WINAPI RegGetValueW( HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, cbData = ExpandEnvironmentStringsW(pvBuf, pvData, pcbData ? *pcbData : 0); dwType = REG_SZ; - if(pcbData && cbData > *pcbData) + if(pvData && pcbData && cbData > *pcbData) ret = ERROR_MORE_DATA; } else if (pvData) @@ -1600,7 +1601,7 @@ LSTATUS WINAPI RegGetValueA( HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, cbData = ExpandEnvironmentStringsA(pvBuf, pvData, pcbData ? *pcbData : 0); dwType = REG_SZ; - if(pcbData && cbData > *pcbData) + if(pvData && pcbData && cbData > *pcbData) ret = ERROR_MORE_DATA; } else if (pvData) diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 2ca2424..11ec71d 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -710,7 +710,7 @@ static void test_get_value(void) 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) */ - size = 0xbadbeef; + size = 0; ret = pRegGetValueA(hkey_main, NULL, "TP1_EXP_SZ", RRF_RT_REG_SZ, NULL, NULL, &size); ok(ret == ERROR_SUCCESS, "ret=%d\n", ret); /* At least v5.2.3790.1830 (2003 SP1) returns the unexpanded sTestpath1 length + 1 here. */