[PATCH v2 3/8] reg: Add check for multiple backslashes at the end of the key
Jonathan Vollebregt
jnvsor at gmail.com
Fri Nov 7 10:29:15 CST 2014
---
programs/reg/reg.c | 8 ++++++++
programs/reg/tests/reg.c | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index c146ce9..ff12b3f 100755
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -78,6 +78,9 @@ static void reg_print_error(LSTATUS error_code)
case ERROR_BAD_COMMAND:
reg_message(STRING_INVALID_CMDLINE);
return;
+ case ERROR_INVALID_HANDLE:
+ reg_message(STRING_INVALID_KEY);
+ return;
case ERROR_NO_REMOTE:
reg_message(STRING_NO_REMOTE);
return;
@@ -194,6 +197,11 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
static LSTATUS sane_path(const WCHAR *key)
{
+ int i = strlenW(key);
+
+ if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\'))
+ return ERROR_INVALID_HANDLE;
+
if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
return ERROR_NO_REMOTE;
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
index f93df55..57e0108 100644
--- a/programs/reg/tests/reg.c
+++ b/programs/reg/tests/reg.c
@@ -129,10 +129,10 @@ static void test_add(void)
ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %u\n", r);
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
- todo_wine ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
+ ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
"got exit code %d\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
--
2.1.1
More information about the wine-patches
mailing list