-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Am 2014-11-04 21:15, schrieb Jonathan Vollebregt:
+static BOOL sane_path(const WCHAR *key) +{
- int i = strlenW(key);
- if (i < 3 || (key[i - 1] == '\' && key[i - 2] == '\'))
- {
reg_print_error(ERROR_BADKEY);
return FALSE;
- }
I think I have asked this a few times, please forgive me if I forgot the answer: Did you test if RegAddKey and friends handle this for you? dlls/advapi32/tests/registry.c would profit from some tests for the error cases you have in programs/reg/tests/reg.c .
if (!sane_path(key_name))
return 1;
for (i = 1; i < argc; i++) { if (!lstrcmpiW(argvW[i], slashVW))
@@ -471,6 +485,9 @@ int wmain(int argc, WCHAR *argvW[]) }
key_name = argvW[2];
if (!sane_path(key_name))
return 1;
for (i = 1; i < argc; i++) { if (!lstrcmpiW(argvW[i], slashVW))
@@ -502,6 +519,9 @@ int wmain(int argc, WCHAR *argvW[]) }
key_name = argvW[2];
if (!sane_path(key_name))
return 1;
The helper function is a good idea if the answer to the above question is "no", but what's the advantage of calling it from main 3 times instead of reg_add, reg_delete and reg_query? All the other validation is done in reg_* .
For consistency with the other functions it would be a good idea to return ERROR_BADKEY / ERROR_NO_REMOTE here and call reg_print_error in the caller.