Jactry Zeng jzeng@codeweavers.com writes:
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/advapi32/tests/registry.c | 46 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-)
I don't see how this is different from the existing tests.
Hi Alexandre, 2017-07-10 16:58 GMT+08:00 Alexandre Julliard julliard@winehq.org:
I don't see how this is different from the existing tests.
Do you mean https://source.winehq.org/git/wine.git/blob/ a94938819280aa52fbc545911ca70a6c3a83ab49:/dlls/advapi32/ tests/registry.c#l1771 ?
The difference is here set an empty string and a zero length for RegSetValueExW:
+ ret = RegSetValueExW(hkey_main, name4W, 0, REG_SZ, (const BYTE *)emptyW, lstrlenW(emptyW));
Later RegQueryValueExW will get a zero length and it will not set buffer[0] as NULL:
+ ret = RegQueryValueExW(hkey_main, name4W, 0, &type, (LPBYTE)buffer, &len); + ok(ret == ERROR_SUCCESS, "RegQueryValueExW failed: %d, GLE=%d\n", ret, GetLastError()); + ok(len == 0, "got wrong length: %d\n", len); + ok(type == REG_SZ, "got type %d\n", type); + ok(!lstrcmpW(buffer, string1W), "got wrong string: %s\n", wine_dbgstr_w(buffer));
I found this because of a notepad bug. It can be reproduced by: 1. $ wine notepad; 2. Open 'page setup' dialog in menu 'File'; 3. Clear string in 'Header' and 'Footer' and then enter it; 4. Restart notepad and open 'page setup' dialog again. 'Header' and 'Footer' will be set as a font name, it is from another registry key of notepad 'lfFaceName'.
Jactry Zeng jactry92@gmail.com writes:
Hi Alexandre, 2017-07-10 16:58 GMT+08:00 Alexandre Julliard julliard@winehq.org:
I don't see how this is different from the existing tests.
Do you mean https://source.winehq.org/git/wine.git/blob/a94938819280aa52fbc545911ca70a6c... ?
The difference is here set an empty string and a zero length for RegSetValueExW:
- ret = RegSetValueExW(hkey_main, name4W, 0, REG_SZ, (const BYTE *)emptyW, lstrlenW(emptyW));
Later RegQueryValueExW will get a zero length and it will not set buffer[0] as NULL:
That's also tested already, in test_hkey_main_Value_A/W.
2017-07-10 17:32 GMT+08:00 Alexandre Julliard julliard@winehq.org:
That's also tested already, in test_hkey_main_Value_A/W.
Aha! Yes, you are right. That was tested. So RegQueryValueExW will not add a NULL terminator all the time, and setting a length with NULL terminator for RegSetValueExW is necessary when using a same buffer for many RegQueryValueExW call.
Jactry Zeng jactry92@gmail.com writes:
2017-07-10 17:32 GMT+08:00 Alexandre Julliard julliard@winehq.org:
That's also tested already, in test_hkey_main_Value_A/W.
Aha! Yes, you are right. That was tested. So RegQueryValueExW will not add a NULL terminator all the time, and setting a length with NULL terminator for RegSetValueExW is necessary when using a same buffer for many RegQueryValueExW call.
In general it would be more robust to check the length from RegQueryValueExW. Fixing the setting side doesn't guarantee anything since it could be changed by some other piece of code.